summaryrefslogtreecommitdiff
path: root/jsmn.c
diff options
context:
space:
mode:
authorSerge A. Zaitsev <zaitsev.serge@gmail.com>2015-10-17 15:14:13 +0200
committerSerge A. Zaitsev <zaitsev.serge@gmail.com>2015-10-17 15:14:13 +0200
commitaedc121ce8a5ef0156ee6cb7e06fcd96457220a0 (patch)
tree94eccdf11cf4437a1c5054c64e073e14e67bf39f /jsmn.c
parent824d9a769c38584c5aef9f6f12642645c66dc055 (diff)
added check for null pointer before fixing tokens after parsing is done
Diffstat (limited to 'jsmn.c')
-rw-r--r--jsmn.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/jsmn.c b/jsmn.c
index 74a62d075..2809669b3 100644
--- a/jsmn.c
+++ b/jsmn.c
@@ -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;
+ }
}
}