aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/HtmlParser.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/HtmlParser.c b/src/HtmlParser.c
index aadf2a8..efc9e27 100644
--- a/src/HtmlParser.c
+++ b/src/HtmlParser.c
@@ -148,14 +148,15 @@ static void html_parser_advance_char(HtmlParser *self) {
++self->offset;
}
-static void html_parser_try_append_unclosed_tag(HtmlParser *self, const char *data, size_t size) {
+static int html_parser_try_append_unclosed_tag(HtmlParser *self, const char *data, size_t size) {
if(self->unclosed_tags_offset == UNCLOSED_TAGS_SIZE) {
fprintf(stderr, "Reached the maximum number of unclosed tags! the html source is too broken\n");
- return;
+ return 1;
}
self->unclosed_tags[self->unclosed_tags_offset].data = data;
self->unclosed_tags[self->unclosed_tags_offset].size = size;
++self->unclosed_tags_offset;
+ return 0;
}
static void html_parser_pop_unclosed_tag(HtmlParser *self) {
@@ -399,7 +400,9 @@ static int html_parser_parse_tag_start(HtmlParser *self) {
if(self->is_tag_void) {
self->tag_before_void_tag = prev_tag_name;
} else {
- html_parser_try_append_unclosed_tag(self, self->tag_name.data, self->tag_name.size);
+ res = html_parser_try_append_unclosed_tag(self, self->tag_name.data, self->tag_name.size);
+ if(res != 0)
+ return res;
self->inside_script_tag = string_view_equals_case_insensitive(&self->tag_name, &script_tag);
}
res = self->parse_callback(self, HTML_PARSE_TAG_START, self->callback_userdata);