diff options
author | Petri Lehtinen <petri@digip.org> | 2011-04-21 13:15:01 +0300 |
---|---|---|
committer | Petri Lehtinen <petri@digip.org> | 2011-04-21 13:15:22 +0300 |
commit | e20619e0718d6c3c6161d4c946b46127ee088861 (patch) | |
tree | b73f821fddcd5792eaae98deda171b2285e18ff8 | |
parent | c96763215dddce8fbd6f785b9c841b5d97458d41 (diff) | |
download | jansson-2.0.zip jansson-2.0.tar.gz jansson-2.0.tar.bz2 |
Fix a leak when memory allocation fails in json_object_set() & friends2.0
-rw-r--r-- | src/value.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/value.c b/src/value.c index 5d8ae22..47ebb2c 100644 --- a/src/value.c +++ b/src/value.c @@ -139,7 +139,10 @@ int json_object_set_new_nocheck(json_t *json, const char *key, json_t *value) allocated. */ k = jsonp_malloc(offsetof(object_key_t, key) + strlen(key) + 1); if(!k) + { + json_decref(value); return -1; + } k->serial = object->serial++; strcpy(k->key, key); |