From 30c389623cb6e4e79adcb97c7f743830fcc843c0 Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Wed, 26 Nov 2014 16:25:07 +0100 Subject: Don't allow insert_{before|after} root node This can be changed if support for node lists is added to the public API. --- src/node.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/node.c b/src/node.c index 8de46ea..8b107bc 100644 --- a/src/node.c +++ b/src/node.c @@ -436,7 +436,7 @@ cmark_node_unlink(cmark_node *node) { int cmark_node_insert_before(cmark_node *node, cmark_node *sibling) { - if (!S_can_contain(node->parent, sibling)) { + if (!node->parent || !S_can_contain(node->parent, sibling)) { return 0; } @@ -467,7 +467,7 @@ cmark_node_insert_before(cmark_node *node, cmark_node *sibling) int cmark_node_insert_after(cmark_node *node, cmark_node *sibling) { - if (!S_can_contain(node->parent, sibling)) { + if (!node->parent || !S_can_contain(node->parent, sibling)) { return 0; } -- cgit v1.2.3