From 6622c54f18a4ad3cd621f4228013fbf6dba1fa88 Mon Sep 17 00:00:00 2001 From: Max Bruckner Date: Mon, 28 Nov 2016 23:06:22 +0700 Subject: [PATCH] Handle out of memory when printing string --- cJSON.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cJSON.c b/cJSON.c index 58a1ffd..3b61798 100644 --- a/cJSON.c +++ b/cJSON.c @@ -1452,7 +1452,10 @@ static char *print_object(const cJSON *item, int depth, cjbool fmt, printbuffer } /* print key */ - print_string_ptr(child->string, p); + if (!print_string_ptr(child->string, p)) + { + return NULL; + } p->offset = update(p); len = fmt ? 2 : 1;