projects
/
jansson.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
c967632
)
Fix a leak when memory allocation fails in json_object_set() & friends
origin/2.0
author
Petri Lehtinen
<petri@digip.org>
Thu, 21 Apr 2011 10:15:01 +0000
(13:15 +0300)
committer
Petri Lehtinen
<petri@digip.org>
Thu, 21 Apr 2011 10:15:22 +0000
(13:15 +0300)
src/value.c
patch
|
blob
|
history
diff --git
a/src/value.c
b/src/value.c
index
5d8ae22
..
47ebb2c
100644
(file)
--- 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);