[sr-dev] git:master:82f13f5d: Merge pull request #284 from jnewmano/master

Daniel-Constantin Mierla miconda at gmail.com
Wed Aug 12 11:17:58 CEST 2015


Module: kamailio
Branch: master
Commit: 82f13f5d020ebd0ce4ff4c692a4e6d6567f5f5b7
URL: https://github.com/kamailio/kamailio/commit/82f13f5d020ebd0ce4ff4c692a4e6d6567f5f5b7

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2015-08-12T11:17:53+02:00

Merge pull request #284 from jnewmano/master

janssonrpc-c: allow null json error property in rpc response

---

Modified: modules/janssonrpc-c/janssonrpc_io.c

---

Diff:  https://github.com/kamailio/kamailio/commit/82f13f5d020ebd0ce4ff4c692a4e6d6567f5f5b7.diff
Patch: https://github.com/kamailio/kamailio/commit/82f13f5d020ebd0ce4ff4c692a4e6d6567f5f5b7.patch

---

diff --git a/modules/janssonrpc-c/janssonrpc_io.c b/modules/janssonrpc-c/janssonrpc_io.c
index ffcc247..1e1a82b 100644
--- a/modules/janssonrpc-c/janssonrpc_io.c
+++ b/modules/janssonrpc-c/janssonrpc_io.c
@@ -587,9 +587,12 @@ int handle_response(json_t* response)
 	return_obj = json_object();
 
 	json_t* error = json_object_get(response, "error");
+	// if the error value is null, we don't care
+	bool _error = error && (json_typeof(error) != JSON_NULL);
+
 	json_t* result = json_object_get(response, "result");
 
-	if(error) {
+	if(_error) {
 		json_object_set(return_obj, "error", error);
 	}
 
@@ -597,7 +600,7 @@ int handle_response(json_t* response)
 		json_object_set(return_obj, "result", result);
 	}
 
-	if ((!result && !error) || (result && error)) {
+	if ((!result && !_error) || (result && _error)) {
 		WARN("bad response\n");
 		internal = internal_error(JRPC_ERR_BAD_RESP, req->payload);
 		json_object_update(return_obj, internal);
@@ -621,7 +624,7 @@ int handle_response(json_t* response)
 		goto free_and_end;
 	}
 
-	if(error) {
+	if(_error) {
 		// get code from error
 		json_t* _code = json_object_get(error, "code");
 		if(_code) {




More information about the sr-dev mailing list