watch out for i+1 to overflow the buffer

pull/5/head
Antonio Cervone 2015-12-02 10:01:29 +01:00
parent 988a8fc249
commit ebc3a6b038
1 changed files with 3 additions and 3 deletions

View File

@ -389,12 +389,12 @@ struct JsonParser {
} }
else if (str[i] == '*') { // multiline comment else if (str[i] == '*') { // multiline comment
i++; i++;
if (i == str.size()) if (i > str.size()-2)
return fail("unexpected end of input inside multi-line comment", 0); return fail("unexpected end of input inside multi-line comment", 0);
// advance until closing tokens // advance until closing tokens
while (!(str[i] == '*' && str[i+1] == '/')) { while (!(str[i] == '*' && str[i+1] == '/')) {
i++; i++;
if (i == str.size()) if (i > str.size()-2)
return fail( return fail(
"unexpected end of input inside multi-line comment", 0); "unexpected end of input inside multi-line comment", 0);
} }