[asterisk-commits] rmudgett: trunk r408712 - in /trunk: ./ main/json.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Feb 21 11:48:00 CST 2014


Author: rmudgett
Date: Fri Feb 21 11:47:58 2014
New Revision: 408712

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=408712
Log:
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

Modified:
    trunk/   (props changed)
    trunk/main/json.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-12-merged' - no diff available.

Modified: trunk/main/json.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/json.c?view=diff&rev=408712&r1=408711&r2=408712
==============================================================================
--- trunk/main/json.c (original)
+++ trunk/main/json.c Fri Feb 21 11:47:58 2014
@@ -466,8 +466,13 @@
 
 	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 @@
 
 	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);
 	}




More information about the asterisk-commits mailing list