Minor fixes to res_json and test_json.

* Made input checking more consistent with other Asterisk code
* Added validation to ast_json_dump_new_file
* Fixed tests for ownereship semantics

(issue ASTERISK-20887)


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@381214 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
David M. Lee
2013-02-11 20:39:11 +00:00
parent 98ef0d3215
commit f2b9c12704
2 changed files with 39 additions and 13 deletions

View File

@@ -242,10 +242,10 @@ size_t ast_json_object_size(struct ast_json *object)
}
struct ast_json *ast_json_object_get(struct ast_json *object, const char *key)
{
if (key) {
return (struct ast_json *)json_object_get((json_t *)object, key);
if (!key) {
return NULL;
}
return NULL;
return (struct ast_json *)json_object_get((json_t *)object, key);
}
int ast_json_object_set(struct ast_json *object, const char *key, struct ast_json *value)
{
@@ -391,13 +391,16 @@ int ast_json_dump_str(struct ast_json *root, struct ast_str **dst)
int ast_json_dump_file(struct ast_json *root, FILE *output)
{
if (root && output) {
return json_dumpf((json_t *)root, output, dump_flags());
if (!root || !output) {
return -1;
}
return -1;
return json_dumpf((json_t *)root, output, dump_flags());
}
int ast_json_dump_new_file(struct ast_json *root, const char *path)
{
if (!root || !path) {
return -1;
}
return json_dump_file((json_t *)root, path, dump_flags());
}