瀏覽代碼

handle null pointers: cJSON_PrintPreallocated

Max Bruckner 8 年之前
父節點
當前提交
56f2bc6f3e
共有 1 個文件被更改,包括 1 次插入1 次删除
  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;
     }