Browse Source

handle null pointers: cJSON_PrintPreallocated

Max Bruckner 8 years ago
parent
commit
56f2bc6f3e
1 changed files with 1 additions and 1 deletions
  1. 1 1
      cJSON.c

+ 1 - 1
cJSON.c

@@ -1122,7 +1122,7 @@ CJSON_PUBLIC(cJSON_bool) cJSON_PrintPreallocated(cJSON *item, char *buf, const i
 {
     printbuffer p = { 0, 0, 0, 0, 0, 0, { 0, 0, 0 } };
 
-    if (len < 0)
+    if ((len < 0) || (buf == NULL))
     {
         return false;
     }