浏览代码

handle null pointer: compose_patch

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

+ 8 - 1
cJSON_Utils.c

@@ -1043,7 +1043,14 @@ CJSON_PUBLIC(int) cJSONUtils_ApplyPatchesCaseSensitive(cJSON * const object, con
 
 static void compose_patch(cJSON * const patches, const unsigned char * const operation, const unsigned char * const path, const unsigned char *suffix, const cJSON * const value)
 {
-    cJSON *patch = cJSON_CreateObject();
+    cJSON *patch = NULL;
+
+    if ((patches == NULL) || (operation == NULL) || (path == NULL))
+    {
+        return;
+    }
+
+    patch = cJSON_CreateObject();
     if (patch == NULL)
     {
         return;