Skip to content

Commit 2553228

Browse files
committed
Removed check for same mem allocator in S_can_contain.
This is too strict, as it prevents the use of dynamically loaded extensions: see commonmark#123 (comment). Documented in man page and public header that one should use the same memory allocator for every node in a tree.
1 parent 66ee8c4 commit 2553228

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

src/cmark.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,8 @@ typedef struct cmark_mem {
112112
CMARK_EXPORT cmark_node *cmark_node_new(cmark_node_type type);
113113

114114
/** Same as `cmark_node_new`, but explicitly listing the memory
115-
* allocator used to allocate the node
115+
* allocator used to allocate the node. Note: be sure to use the same
116+
* allocator for every node in a tree, or bad things can happen.
116117
*/
117118
CMARK_EXPORT cmark_node *cmark_node_new_with_mem(cmark_node_type type, cmark_mem *mem);
118119

src/node.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@ static bool S_can_contain(cmark_node *node, cmark_node *child) {
3030
if (node == NULL || child == NULL) {
3131
return false;
3232
}
33-
if (NODE_MEM(node) != NODE_MEM(child)) {
34-
return 0;
35-
}
3633

3734
// Verify that child is not an ancestor of node or equal to node.
3835
cur = node;

0 commit comments

Comments
 (0)