cJSON

mirror of Dave's cJSON
git clone git://git.thc420.xyz/cJSON
Log | Files | Refs | README | LICENSE

commit 0d10e279c8b604f71829b5d49d092719f4ae96b6
parent 9e310491597151fcf783191fd5df05c363b09b50
Author: Max Bruckner <max@maxbruckner.de>
Date:   Fri, 11 Nov 2016 11:53:14 +0700

fix #55 memory leak in cJSON_ReplaceItemInObject

Diffstat:
McJSON.c | 6++++++
1 file changed, 6 insertions(+), 0 deletions(-)

diff --git a/cJSON.c b/cJSON.c @@ -1861,6 +1861,12 @@ void cJSON_ReplaceItemInObject(cJSON *object, const char *string, cJSON *newitem } if(c) { + /* free the old string if not const */ + if (!(newitem->type & cJSON_StringIsConst) && newitem->string) + { + cJSON_free(newitem->string); + } + newitem->string = cJSON_strdup(string); cJSON_ReplaceItemInArray(object, i, newitem); }