From 176a26ab0dba12d8c053376f32e5accba9e9166a Mon Sep 17 00:00:00 2001 From: schwarze Date: Wed, 8 Jun 2022 16:29:12 +0000 Subject: [PATCH] When looking for the next block to tag, we aren't interested in children of the current block but really want the next block instead. This fixes a segfault reported by Evan Silberman on bugs@. --- usr.bin/mandoc/mdoc_validate.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/usr.bin/mandoc/mdoc_validate.c b/usr.bin/mandoc/mdoc_validate.c index 9e681af4b50..aa47566638a 100644 --- a/usr.bin/mandoc/mdoc_validate.c +++ b/usr.bin/mandoc/mdoc_validate.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mdoc_validate.c,v 1.305 2021/10/04 14:18:42 schwarze Exp $ */ +/* $OpenBSD: mdoc_validate.c,v 1.306 2022/06/08 16:29:12 schwarze Exp $ */ /* * Copyright (c) 2010-2021 Ingo Schwarze * Copyright (c) 2008-2012 Kristaps Dzonsons @@ -1098,7 +1098,8 @@ post_tg(POST_ARGS) /* Find the next node. */ n = mdoc->last; for (nn = n; nn != NULL; nn = nn->parent) { - if (nn->next != NULL) { + if (nn->type != ROFFT_HEAD && nn->type != ROFFT_BODY && + nn->type != ROFFT_TAIL && nn->next != NULL) { nn = nn->next; break; } -- 2.20.1