From 9cca6ef2f9fb9e7051db1ff1ea7a84df9d99a1ac Mon Sep 17 00:00:00 2001 From: Gao feng Date: Thu, 26 May 2016 15:38:00 +0800 Subject: [PATCH] handle null route json message Signed-off-by: Gao feng --- src/parse.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/parse.c b/src/parse.c index 0ccd337..b0736ab 100644 --- a/src/parse.c +++ b/src/parse.c @@ -860,6 +860,7 @@ int hyper_parse_setup_routes(struct hyper_route **routes, uint32_t *r_num, char jsmn_parser p; int toks_num = 10, i, n, ret = -1; jsmntok_t *toks = NULL; + int found = 0; realloc: toks = realloc(toks, toks_num * sizeof(jsmntok_t)); @@ -889,11 +890,11 @@ realloc: fprintf(stderr, "cannot find routes\n"); goto out; } - + found = 1; break; } - if (hyper_parse_routes(routes, r_num, json, &toks[i]) < 0) { + if (found && (hyper_parse_routes(routes, r_num, json, &toks[i]) < 0)) { fprintf(stdout, "fail to parse routes\n"); goto out; }