Fix infinite loop on unterminated string in query

This commit is contained in:
Max Brunsfeld 2019-09-11 14:44:49 -07:00
parent a1fec71b19
commit 86205b9e6d
2 changed files with 9 additions and 3 deletions

View file

@ -398,7 +398,12 @@ static TSQueryError ts_query_parse_pattern(
// Parse the string content
const char *string_content = stream->input;
while (stream->next && stream->next != '"') stream_advance(stream);
while (stream->next != '"') {
if (!stream_advance(stream)) {
stream_reset(stream, string_content - 1);
return TSQueryErrorSyntax;
}
}
uint32_t length = stream->input - string_content;
// Add a step for the node