Browse Source

handle null pointers: cJSON_AddItemReferenceToArray

Max Bruckner 8 years ago
parent
commit
c179509b31
1 changed files with 5 additions and 0 deletions
  1. 5 0
      cJSON.c

+ 5 - 0
cJSON.c

@@ -1844,6 +1844,11 @@ CJSON_PUBLIC(void) cJSON_AddItemToObjectCS(cJSON *object, const char *string, cJ
 
 CJSON_PUBLIC(void) cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item)
 {
+    if (array == NULL)
+    {
+        return;
+    }
+
     cJSON_AddItemToArray(array, create_reference(item, &global_hooks));
 }