diff --git a/cJSON.c b/cJSON.c index cfb5057f22cdbc057333229f38840b3397ab3746..1fc2e39ad42de0597e86c282dccbec737ba882cc 100644 --- a/cJSON.c +++ b/cJSON.c @@ -845,6 +845,10 @@ char *cJSON_PrintBuffered(const cJSON *item, int prebuffer, int fmt) { printbuffer p; p.buffer = (char*)cJSON_malloc(prebuffer); + if (!p.buffer) + { + return 0; + } p.length = prebuffer; p.offset = 0;