Skip to content

Commit d5b5f76

Browse files
fix: add buffer cleaning
1 parent 9e965c9 commit d5b5f76

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

cpp/parser/GumboNormalizer.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -517,8 +517,8 @@ static void flush_inline_p(buffer_t *ib, buffer_t *out) {
517517
buffer_append_str(out, "<p>");
518518
buffer_append(out, ib->data, ib->len);
519519
buffer_append_str(out, "</p>");
520-
buffer_clear(ib);
521520
}
521+
buffer_clear(ib);
522522
}
523523

524524
static void flatten_bq_children(GumboNode *node, buffer_t *ib, buffer_t *out) {
@@ -692,8 +692,10 @@ static void walk_children(GumboNode *node, buffer_t *out) {
692692
/* Whitespace-only buffer is layout noise; treat like empty → <br> */
693693
if (ib.len > 0 && !is_whitespace_only(ib.data, ib.len))
694694
flush_inline_p(&ib, out);
695-
else
695+
else {
696+
buffer_clear(&ib);
696697
buffer_append_str(out, "<br>");
698+
}
697699
i++;
698700
continue;
699701
}

0 commit comments

Comments
 (0)