jsmn: bugfix in jsmn_parse() (found by clang).
authorDario Lombardo <lomato@gmail.com>
Fri, 6 Mar 2015 13:43:43 +0000 (14:43 +0100)
committerPascal Quantin <pascal.quantin@gmail.com>
Fri, 6 Mar 2015 19:48:00 +0000 (19:48 +0000)
Change-Id: Id5a9888a3e17c861a9de06343bd99ec0c4aacdce
Reviewed-on: https://code.wireshark.org/review/7555
Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
wsutil/jsmn.c

index fdfd3a74cce0cf5e8abacc30c02037da816b4093..79cf363fffe7efe92444ef1706b7bfa1352c44e6 100644 (file)
@@ -317,10 +317,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;
+                       }
                }
        }