From 5aac0be13a65b396fd1c62ff95fb8657cc109a32 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Fri, 19 Nov 2021 10:49:54 +0000 Subject: [PATCH] [Minor] Add safe-guard for the root tag --- src/libserver/html/html.cxx | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/libserver/html/html.cxx b/src/libserver/html/html.cxx index 5260ba690..a920f9a4f 100644 --- a/src/libserver/html/html.cxx +++ b/src/libserver/html/html.cxx @@ -1400,18 +1400,20 @@ html_process_input(rspamd_mempool_t *pool, } if (pt) { + g_assert(cur_tag != pt); cur_tag->parent = pt; - g_assert(cur_tag->parent != cur_tag); g_assert(cur_tag->parent != &cur_closing_tag); parent_tag = pt; parent_tag->children.push_back(cur_tag); } else { if (hc->root_tag) { - cur_tag->parent = hc->root_tag; - g_assert(cur_tag->parent != cur_tag); - hc->root_tag->children.push_back(cur_tag); - parent_tag = hc->root_tag; + if (cur_tag != hc->root_tag) { + cur_tag->parent = hc->root_tag; + g_assert(cur_tag->parent != cur_tag); + hc->root_tag->children.push_back(cur_tag); + parent_tag = hc->root_tag; + } } else { if (cur_tag->id == Tag_HTML) { -- 2.39.5