]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Add safe-guard for the root tag
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 19 Nov 2021 10:49:54 +0000 (10:49 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 19 Nov 2021 10:49:54 +0000 (10:49 +0000)
src/libserver/html/html.cxx

index 5260ba690d7d319b7f6756040f6192500e605c8b..a920f9a4f544fbcedf08d1c6e03b24ae5dc7c4e7 100644 (file)
@@ -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) {