From 264abd48de5a8d2ddbbf3f0bfb6b3c632d61800d Mon Sep 17 00:00:00 2001 From: Eric Fischer Date: Wed, 5 Feb 2014 21:52:39 -0800 Subject: [PATCH] Fix crash with comma or colon at the top level. --- jsonpull.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/jsonpull.c b/jsonpull.c index 15552ae..20d650c 100644 --- a/jsonpull.c +++ b/jsonpull.c @@ -171,6 +171,10 @@ json_object *json_parse(FILE *f, json_object *current) { /////////////////////////// Comma if (c == ',') { + if (current == NULL) { + json_error("comma at top level"); + } + if (current->parent == NULL || (current->parent->type != JSON_ARRAY && current->parent->type != JSON_HASH)) { @@ -183,6 +187,10 @@ json_object *json_parse(FILE *f, json_object *current) { /////////////////////////// Colon if (c == ':') { + if (current == NULL) { + json_error("colon at top level"); + } + if (current->parent == NULL || current->parent->type != JSON_HASH) { json_error(": not in hash\n"); }