diff options
Diffstat (limited to 'libs/litehtml/src/gumbo/tokenizer.c')
-rw-r--r-- | libs/litehtml/src/gumbo/tokenizer.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/libs/litehtml/src/gumbo/tokenizer.c b/libs/litehtml/src/gumbo/tokenizer.c index 0d0ea0f241..71b5d32ad4 100644 --- a/libs/litehtml/src/gumbo/tokenizer.c +++ b/libs/litehtml/src/gumbo/tokenizer.c @@ -377,7 +377,7 @@ static bool temporary_buffer_equals(GumboParser* parser, const char* text) { // TODO(jdtang): See if the extra strlen is a performance problem, and replace // it with an explicit sizeof(literal) if necessary. I don't think it will // be, as this is only used in a couple of rare states. - size_t text_len = strlen(text); + int text_len = strlen(text); return text_len == buffer->length && memcmp(buffer->data, text, text_len) == 0; } @@ -726,7 +726,8 @@ static void copy_over_original_tag_text(GumboParser* parser, original_text->data = tag_state->_original_text; original_text->length = utf8iterator_get_char_pointer(&tokenizer->_input) - tag_state->_original_text; - if (original_text->data[original_text->length - 1] == '\r') { + if (original_text->length > 0 + && original_text->data[original_text->length - 1] == '\r') { // Since \r is skipped by the UTF-8 iterator, it can sometimes end up // appended to the end of original text even when it's really the first part // of the next character. If we detect this situation, shrink the length of @@ -751,7 +752,7 @@ static void finish_tag_name(GumboParser* parser) { GumboTagState* tag_state = &tokenizer->_tag_state; tag_state->_tag = - gumbo_tagn_enum(tag_state->_buffer.data, (unsigned)tag_state->_buffer.length); + gumbo_tagn_enum(tag_state->_buffer.data, tag_state->_buffer.length); reinitialize_tag_buffer(parser); } @@ -839,7 +840,7 @@ static bool is_appropriate_end_tag(GumboParser* parser) { assert(!tag_state->_is_start_tag); return tag_state->_last_start_tag != GUMBO_TAG_LAST && tag_state->_last_start_tag == gumbo_tagn_enum(tag_state->_buffer.data, - (unsigned)tag_state->_buffer.length); + tag_state->_buffer.length); } void gumbo_tokenizer_state_init( |