diff options
author | Petri Lehtinen <petri@digip.org> | 2009-08-04 20:54:47 +0300 |
---|---|---|
committer | Petri Lehtinen <petri@digip.org> | 2009-08-04 20:58:02 +0300 |
commit | 0428f48d19b5206547d9b4ea010ff41eb5e5d92d (patch) | |
tree | e1794f3583d6d6d73d1b81ab016381327eae27b2 /src | |
parent | 36530d8c2584815c8a35ab3c21a427b0a03e539c (diff) | |
download | jansson-0428f48d19b5206547d9b4ea010ff41eb5e5d92d.zip jansson-0428f48d19b5206547d9b4ea010ff41eb5e5d92d.tar.gz jansson-0428f48d19b5206547d9b4ea010ff41eb5e5d92d.tar.bz2 |
Refuse to dump other types than array and object as the root value
Diffstat (limited to 'src')
-rw-r--r-- | src/dump.c | 6 |
1 files changed, 6 insertions, 0 deletions
@@ -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); |