[svn-commits] rmudgett: branch 12 r408711 - /branches/12/main/json.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Fri Feb 21 11:43:06 CST 2014


Author: rmudgett
Date: Fri Feb 21 11:43:00 2014
New Revision: 408711

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

Modified:
    branches/12/main/json.c

Modified: branches/12/main/json.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/main/json.c?view=diff&rev=408711&r1=408710&r2=408711
==============================================================================
--- branches/12/main/json.c (original)
+++ branches/12/main/json.c Fri Feb 21 11:43:00 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 svn-commits mailing list