diff options
author | Steve Bennett <steveb@workware.net.au> | 2019-07-01 12:58:03 +1000 |
---|---|---|
committer | Steve Bennett <steveb@workware.net.au> | 2019-11-09 19:59:14 +1000 |
commit | 529c84b4ee31f51925a9ac14247a94a428592c7d (patch) | |
tree | 1e464ad79551813546477b875ac7de3c24b2caf5 /jsmn/jsmn.c | |
parent | bc7bdabea89c2a21dc41082ae469ee5238338d77 (diff) | |
download | jimtcl-529c84b4ee31f51925a9ac14247a94a428592c7d.zip jimtcl-529c84b4ee31f51925a9ac14247a94a428592c7d.tar.gz jimtcl-529c84b4ee31f51925a9ac14247a94a428592c7d.tar.bz2 |
jsmn: Fix a parser bug where object keys could be non-strings
Signed-off-by: Steve Bennett <steveb@workware.net.au>
Diffstat (limited to 'jsmn/jsmn.c')
-rw-r--r-- | jsmn/jsmn.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/jsmn/jsmn.c b/jsmn/jsmn.c index 853c3f1..2de5ec2 100644 --- a/jsmn/jsmn.c +++ b/jsmn/jsmn.c @@ -170,6 +170,10 @@ int jsmn_parse(jsmn_parser *parser, const char *js, size_t len, if (token == NULL) return JSMN_ERROR_NOMEM; if (parser->toksuper != -1) { + if (tokens[parser->toksuper].type == JSMN_OBJECT) { + /* Object keys must be strings, not objects or arrays */ + return JSMN_ERROR_INVAL; + } tokens[parser->toksuper].size++; #ifdef JSMN_PARENT_LINKS token->parent = parser->toksuper; |