From af04595fe243554ee762f515c088f99ce26e2b27 Mon Sep 17 00:00:00 2001 From: "Serge A. Zaitsev" Date: Thu, 2 Feb 2012 14:05:47 +0200 Subject: [PATCH] fix: error is returned if brackets are unmatched --- jsmn.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/jsmn.c b/jsmn.c index e38a472..cc300e3 100644 --- a/jsmn.c +++ b/jsmn.c @@ -161,6 +161,8 @@ jsmnerr_t jsmn_parse(jsmn_parser *parser, const char *js, jsmntok_t *tokens, break; } } + /* Error if unmatched closing bracket */ + if (i == -1) return JSMN_ERROR_INVAL; for (; i >= 0; i--) { token = &tokens[i]; if (token->start != -1 && token->end == -1) {