Skip to content

Commit

Permalink
added check for null pointer before fixing tokens after parsing is done
Browse files Browse the repository at this point in the history
  • Loading branch information
zserge committed Oct 17, 2015
1 parent 824d9a7 commit aedc121
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions jsmn.c
Original file line number Diff line number Diff line change
Expand Up @@ -289,10 +289,12 @@ int jsmn_parse(jsmn_parser *parser, const char *js, size_t len,
}
}

for (i = parser->toknext - 1; i >= 0; i--) {
/* Unmatched opened object or array */
if (tokens[i].start != -1 && tokens[i].end == -1) {
return JSMN_ERROR_PART;
if (tokens != NULL) {
for (i = parser->toknext - 1; i >= 0; i--) {
/* Unmatched opened object or array */
if (tokens[i].start != -1 && tokens[i].end == -1) {
return JSMN_ERROR_PART;
}
}
}

Expand Down

0 comments on commit aedc121

Please sign in to comment.