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 77#include "syntax_extension.h"
88
99CMARK_DEFINE_LOCK (nextflag )
10+ CMARK_DEFINE_LOCK (safety )
1011
1112/**
1213 * Expensive safety checks are off by default, but can be enabled
@@ -15,7 +16,20 @@ CMARK_DEFINE_LOCK(nextflag)
1516static bool enable_safety_checks = false;
1617
1718void cmark_enable_safety_checks (bool enable ) {
19+ CMARK_INITIALIZE_AND_LOCK (safety );
1820 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 ;
1933}
2034
2135static void S_node_unlink (cmark_node * node );
@@ -95,7 +109,7 @@ static bool S_can_contain(cmark_node *node, cmark_node *child) {
95109 return 0 ;
96110 }
97111
98- if (enable_safety_checks ) {
112+ if (S_safety_checks_enabled () ) {
99113 // Verify that child is not an ancestor of node or equal to node.
100114 cmark_node * cur = node ;
101115 do {
You can’t perform that action at this time.
0 commit comments