aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Nicolas "Pixel" Noble <pixel@nobis-crew.org>2016-04-01 00:53:57 +0200
committerGravatar Nicolas "Pixel" Noble <pixel@nobis-crew.org>2016-04-01 00:53:57 +0200
commit959b6f52cda3555a92e8a7c52f213560960ce614 (patch)
treee570d5249f3c583cb6660026a58c53480bd49c5b
parent5d28d9f63bf9bed97f6f9338668f97020ed40766 (diff)
Fixing another memory leak.
-rw-r--r--src/core/lib/json/json_reader.c4
-rw-r--r--test/core/json/json_test.c1
2 files changed, 4 insertions, 1 deletions
diff --git a/src/core/lib/json/json_reader.c b/src/core/lib/json/json_reader.c
index 098e089eed..9e18135b32 100644
--- a/src/core/lib/json/json_reader.c
+++ b/src/core/lib/json/json_reader.c
@@ -202,8 +202,10 @@ grpc_json_reader_status grpc_json_reader_run(grpc_json_reader *reader) {
}
if (reader->in_object) {
reader->state = GRPC_JSON_STATE_OBJECT_KEY_BEGIN;
- } else {
+ } else if (reader->in_array) {
reader->state = GRPC_JSON_STATE_VALUE_BEGIN;
+ } else {
+ return GRPC_JSON_PARSE_ERROR;
}
} else {
if (reader->depth-- == 0) return GRPC_JSON_PARSE_ERROR;
diff --git a/test/core/json/json_test.c b/test/core/json/json_test.c
index 735ff4c853..7ea5caca5b 100644
--- a/test/core/json/json_test.c
+++ b/test/core/json/json_test.c
@@ -90,6 +90,7 @@ static testing_pair testing_pairs[] = {
{"{\"foo\": bar\"x\"}", NULL},
{"fals", NULL},
{"0,0 ", NULL},
+ {"\"foo\",[]", NULL},
/* Testing unterminated string. */
{"\"\\x", NULL},
/* Testing invalid UTF-16 number. */