projects
/
jansson.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
36530d8
)
Refuse to dump other types than array and object as the root value
author
Petri Lehtinen
<petri@digip.org>
Tue, 4 Aug 2009 17:54:47 +0000
(20:54 +0300)
committer
Petri Lehtinen
<petri@digip.org>
Tue, 4 Aug 2009 17:58:02 +0000
(20:58 +0300)
src/dump.c
patch
|
blob
|
history
diff --git
a/src/dump.c
b/src/dump.c
index
c00260c
..
4831873
100644
(file)
--- a/
src/dump.c
+++ b/
src/dump.c
@@
-237,6
+237,9
@@
char *json_dumps(const json_t *json, uint32_t flags)
strbuffer_t strbuff;
char *result;
+ if(!json_is_array(json) && !json_is_object(json))
+ return NULL;
+
if(strbuffer_init(&strbuff))
return NULL;
@@
-254,6
+257,9
@@
char *json_dumps(const json_t *json, uint32_t flags)
int json_dumpf(const json_t *json, FILE *output, uint32_t flags)
{
+ if(!json_is_array(json) && !json_is_object(json))
+ return -1;
+
if(do_dump(json, flags, 0, dump_to_file, (void *)output))
return -1;
return dump_to_file("\n", 1, (void *)output);