From 631dcbd03b42795bbc37c57d62a32f1ebbe3f1b9 Mon Sep 17 00:00:00 2001 From: Ingo Schwarze Date: Fri, 1 May 2015 16:58:33 +0000 Subject: mdoc_valid_post() may indirectly call roff_node_unlink() which may set ROFF_NEXT_CHILD, which is desirable for the final call to mdoc_valid_post() - in case the target itself gets deleted, the parse point may need this adjustment - but not for the intermediate calls - if intermediate nodes get deleted, that mustn't clobber the parse point. So move setting ROFF_NEXT_SIBLING to the proper place in rew_last(). This fixes the assertion failure in jsg@'s afl test case 108/Apr27. --- mdoc_macro.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mdoc_macro.c b/mdoc_macro.c index d87da2cf..04ea9423 100644 --- a/mdoc_macro.c +++ b/mdoc_macro.c @@ -1,4 +1,4 @@ -/* $Id: mdoc_macro.c,v 1.199 2015/05/01 16:02:47 schwarze Exp $ */ +/* $Id: mdoc_macro.c,v 1.200 2015/05/01 16:58:33 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons * Copyright (c) 2010, 2012-2015 Ingo Schwarze @@ -263,7 +263,6 @@ rew_last(struct roff_man *mdoc, const struct roff_node *to) if (to->flags & MDOC_VALID) return; - mdoc->next = ROFF_NEXT_SIBLING; while (mdoc->last != to) { /* * Save the parent here, because we may delete the @@ -276,6 +275,7 @@ rew_last(struct roff_man *mdoc, const struct roff_node *to) mdoc->last = np; assert(mdoc->last); } + mdoc->next = ROFF_NEXT_SIBLING; mdoc_valid_post(mdoc); } -- cgit v1.2.3-56-ge451