浏览代码

handle null pointer: cJSONUtils_FindPointerFromObjectTo

Max Bruckner 8 年之前
父节点
当前提交
9bdf19fde1
共有 1 个文件被更改,包括 5 次插入0 次删除
  1. 5 0
      cJSON_Utils.c

+ 5 - 0
cJSON_Utils.c

@@ -162,6 +162,11 @@ CJSON_PUBLIC(char *) cJSONUtils_FindPointerFromObjectTo(const cJSON * const obje
     size_t child_index = 0;
     cJSON *current_child = 0;
 
+    if ((object == NULL) || (target == NULL))
+    {
+        return NULL;
+    }
+
     if (object == target)
     {
         /* found */