From 4d1dcaa160980bbe6f09a67fac63027f46c3f2c2 Mon Sep 17 00:00:00 2001 From: Kyle Chisholm Date: Mon, 28 Nov 2016 03:20:34 -0500 Subject: [PATCH] check print_value return --- cJSON.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/cJSON.c b/cJSON.c index 4263c9b..707fe44 100644 --- a/cJSON.c +++ b/cJSON.c @@ -1154,8 +1154,7 @@ static char *print_array(const cJSON *item, int depth, cjbool fmt, printbuffer * child = item->child; while (child && !fail) { - ptr = print_value(child, depth + 1, fmt, p); - if (!ptr) + if (!print_value(child, depth + 1, fmt, p)) { return NULL; } @@ -1472,7 +1471,10 @@ static char *print_object(const cJSON *item, int depth, cjbool fmt, printbuffer p->offset+=len; /* print value */ - print_value(child, depth, fmt, p); + if (!print_value(child, depth, fmt, p)) + { + return NULL; + }; p->offset = update(p); /* print comma if not last */