From d277f3ec3ee7a7a38971f5da56bd79347ac6bf9a Mon Sep 17 00:00:00 2001 From: Richard Mudgett Date: Fri, 21 Feb 2014 18:04:54 +0000 Subject: json: Fix off-nominal json ref counting issues. * Fixed off-nominal json ref counting issue with using the following API calls: ast_json_object_set() and ast_json_array_append(). * Fixed off-nominal error reporting in ast_ari_endpoints_list(). * Fixed some miscellaneous off-nominal json ref counting issues in report_receive_fax_status() and dial_to_json(). ........ Merged revisions 408713 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@408714 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- main/sorcery.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'main/sorcery.c') diff --git a/main/sorcery.c b/main/sorcery.c index 5104e3ada..bbdfa8cf2 100644 --- a/main/sorcery.c +++ b/main/sorcery.c @@ -1095,8 +1095,7 @@ struct ast_json *ast_sorcery_objectset_json_create(const struct ast_sorcery *sor for (field = tmp; field; field = field->next) { struct ast_json *value = ast_json_string_create(field->value); - if (value && ast_json_object_set(json, field->name, value)) { - ast_json_unref(value); + if (!value || ast_json_object_set(json, field->name, value)) { res = -1; } } @@ -1106,10 +1105,9 @@ struct ast_json *ast_sorcery_objectset_json_create(const struct ast_sorcery *sor char *buf = NULL; struct ast_json *value = NULL; - if ((res = object_field->handler(object, object_field->args, &buf)) || - !(value = ast_json_string_create(buf)) || - ast_json_object_set(json, object_field->name, value)) { - ast_json_unref(value); + if ((res = object_field->handler(object, object_field->args, &buf)) + || !(value = ast_json_string_create(buf)) + || ast_json_object_set(json, object_field->name, value)) { res = -1; } -- cgit v1.2.3