Przeglądaj źródła

handle null pointers: cJSON_PrintPreallocated

Max Bruckner 8 lat temu
rodzic
commit
56f2bc6f3e
1 zmienionych plików z 1 dodań i 1 usunięć
  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;
     }