mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-02 19:16:15 +00:00
json: Fix json API wrapper code for json library versions earlier than 2.3.0.
* Fixed json ref counting issue with json API wrapper code for ast_json_object_update_existing() and ast_json_object_update_missing() when the json library is earlier than version 2.3.0. ........ Merged revisions 408711 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@408712 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
14
main/json.c
14
main/json.c
@@ -466,8 +466,13 @@ int ast_json_object_update_existing(struct ast_json *object, struct ast_json *ot
|
||||
|
||||
while (iter != NULL && ret == 0) {
|
||||
const char *key = ast_json_object_iter_key(iter);
|
||||
|
||||
if (ast_json_object_get(object, key) != NULL) {
|
||||
ret = ast_json_object_set(object, key, ast_json_object_iter_value(iter));
|
||||
struct ast_json *value = ast_json_object_iter_value(iter);
|
||||
|
||||
if (!value || ast_json_object_set(object, key, ast_json_ref(value))) {
|
||||
ret = -1;
|
||||
}
|
||||
}
|
||||
iter = ast_json_object_iter_next(other, iter);
|
||||
}
|
||||
@@ -488,8 +493,13 @@ int ast_json_object_update_missing(struct ast_json *object, struct ast_json *oth
|
||||
|
||||
while (iter != NULL && ret == 0) {
|
||||
const char *key = ast_json_object_iter_key(iter);
|
||||
|
||||
if (ast_json_object_get(object, key) == NULL) {
|
||||
ret = ast_json_object_set(object, key, ast_json_object_iter_value(iter));
|
||||
struct ast_json *value = ast_json_object_iter_value(iter);
|
||||
|
||||
if (!value || ast_json_object_set(object, key, ast_json_ref(value))) {
|
||||
ret = -1;
|
||||
}
|
||||
}
|
||||
iter = ast_json_object_iter_next(other, iter);
|
||||
}
|
||||
|
Reference in New Issue
Block a user