소스 검색

Merge pull request #81 from alperakcan/master

fix memory leak in cJSON_Duplicate
Max Bruckner 8 년 전
부모
커밋
eeb6d237b6
1개의 변경된 파일1개의 추가작업 그리고 1개의 파일을 삭제
  1. 1 1
      cJSON.c

+ 1 - 1
cJSON.c

@@ -2153,7 +2153,7 @@ cJSON *cJSON_Duplicate(const cJSON *item, cjbool recurse)
     }
     if (item->string)
     {
-        newitem->string = cJSON_strdup(item->string);
+        newitem->string = (item->type&cJSON_StringIsConst) ? item->string : cJSON_strdup(item->string);
         if (!newitem->string)
         {
             cJSON_Delete(newitem);