File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change 7
7
#include "syntax_extension.h"
8
8
9
9
CMARK_DEFINE_LOCK (nextflag )
10
+ CMARK_DEFINE_LOCK (safety )
10
11
11
12
/**
12
13
* Expensive safety checks are off by default, but can be enabled
@@ -15,7 +16,20 @@ CMARK_DEFINE_LOCK(nextflag)
15
16
static bool enable_safety_checks = false;
16
17
17
18
void cmark_enable_safety_checks (bool enable ) {
19
+ CMARK_INITIALIZE_AND_LOCK (safety );
18
20
enable_safety_checks = enable ;
21
+ CMARK_UNLOCK (safety );
22
+ }
23
+
24
+ /**
25
+ * Check whether safety checks have been enabled in a function to guard access
26
+ * behind a lock.
27
+ */
28
+ static bool S_safety_checks_enabled () {
29
+ CMARK_INITIALIZE_AND_LOCK (safety );
30
+ bool safety_enabled = enable_safety_checks ;
31
+ CMARK_UNLOCK (safety );
32
+ return safety_enabled ;
19
33
}
20
34
21
35
static void S_node_unlink (cmark_node * node );
@@ -95,7 +109,7 @@ static bool S_can_contain(cmark_node *node, cmark_node *child) {
95
109
return 0 ;
96
110
}
97
111
98
- if (enable_safety_checks ) {
112
+ if (S_safety_checks_enabled () ) {
99
113
// Verify that child is not an ancestor of node or equal to node.
100
114
cmark_node * cur = node ;
101
115
do {
You can’t perform that action at this time.
0 commit comments