projects
/
jansson.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
7699979
)
json_dumps: Close the strbuffer if dumping fails
author
Petri Lehtinen
<petri@digip.org>
Thu, 15 Oct 2009 17:54:32 +0000
(20:54 +0300)
committer
Petri Lehtinen
<petri@digip.org>
Thu, 15 Oct 2009 17:54:32 +0000
(20:54 +0300)
src/dump.c
patch
|
blob
|
history
diff --git
a/src/dump.c
b/src/dump.c
index
dad64f8
..
1ab1140
100644
(file)
--- a/
src/dump.c
+++ b/
src/dump.c
@@
-242,11
+242,15
@@
char *json_dumps(const json_t *json, unsigned long flags)
if(strbuffer_init(&strbuff))
return NULL;
if(strbuffer_init(&strbuff))
return NULL;
- if(do_dump(json, flags, 0, dump_to_strbuffer, (void *)&strbuff))
+ if(do_dump(json, flags, 0, dump_to_strbuffer, (void *)&strbuff)) {
+ strbuffer_close(&strbuff);
return NULL;
return NULL;
+ }
- if(dump_to_strbuffer("\n", 1, (void *)&strbuff))
+ if(dump_to_strbuffer("\n", 1, (void *)&strbuff)) {
+ strbuffer_close(&strbuff);
return NULL;
return NULL;
+ }
result = strdup(strbuffer_value(&strbuff));
strbuffer_close(&strbuff);
result = strdup(strbuffer_value(&strbuff));
strbuffer_close(&strbuff);