celix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bpe...@apache.org
Subject celix git commit: CELIX-237: add additional status check to prevent segault in case mthod is not available
Date Tue, 17 Nov 2015 08:53:56 GMT
Repository: celix
Updated Branches:
  refs/heads/develop d2593f233 -> 0bedfaa4c


CELIX-237: add additional status check to prevent segault in case mthod is not available


Project: http://git-wip-us.apache.org/repos/asf/celix/repo
Commit: http://git-wip-us.apache.org/repos/asf/celix/commit/0bedfaa4
Tree: http://git-wip-us.apache.org/repos/asf/celix/tree/0bedfaa4
Diff: http://git-wip-us.apache.org/repos/asf/celix/diff/0bedfaa4

Branch: refs/heads/develop
Commit: 0bedfaa4c4e662958139cdfcadb2f80edcdfb9c0
Parents: d2593f2
Author: Bjoern Petri <bpetri@apache.org>
Authored: Tue Nov 17 09:53:27 2015 +0100
Committer: Bjoern Petri <bpetri@apache.org>
Committed: Tue Nov 17 09:53:27 2015 +0100

----------------------------------------------------------------------
 .../dynamic_function_interface/json_rpc.c        | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/celix/blob/0bedfaa4/remote_services/remote_service_admin_dfi/dynamic_function_interface/json_rpc.c
----------------------------------------------------------------------
diff --git a/remote_services/remote_service_admin_dfi/dynamic_function_interface/json_rpc.c
b/remote_services/remote_service_admin_dfi/dynamic_function_interface/json_rpc.c
index dea4f7a..e13c8ef 100644
--- a/remote_services/remote_service_admin_dfi/dynamic_function_interface/json_rpc.c
+++ b/remote_services/remote_service_admin_dfi/dynamic_function_interface/json_rpc.c
@@ -41,6 +41,8 @@ struct generic_service_layout {
 int jsonRpc_call(dyn_interface_type *intf, void *service, const char *request, char **out)
{
     int status = OK;
 
+    dyn_type* returnType = NULL;
+
     LOG_DEBUG("Parsing data: %s\n", request);
     json_error_t error;
     json_t *js_request = json_loads(request, 0, &error);
@@ -72,11 +74,12 @@ int jsonRpc_call(dyn_interface_type *intf, void *service, const char *request,
c
     if (method == NULL) {
         status = ERROR;
         LOG_ERROR("Cannot find method with sig '%s'", sig);
-    } else {
-        LOG_DEBUG("RSA: found method '%s'\n", entry->id);
     }
 
-    dyn_type *returnType = dynFunction_returnType(method->dynFunc);
+    if (status == OK) {
+        LOG_DEBUG("RSA: found method '%s'\n", entry->id);
+        returnType = dynFunction_returnType(method->dynFunc);
+    }
 
     void (*fp)(void) = NULL;
     void *handle = NULL;
@@ -123,10 +126,12 @@ int jsonRpc_call(dyn_interface_type *intf, void *service, const char
*request, c
     }
     json_decref(js_request);
 
-    if (dynType_descriptorType(returnType) != 'N') {
-        //NOTE To be able to handle exception only N as returnType is supported
-        LOG_ERROR("Only interface methods with a native int are supported. Found type '%c'",
(char)dynType_descriptorType(returnType));
-        status = ERROR;
+    if (status == OK) {
+		if (dynType_descriptorType(returnType) != 'N') {
+			//NOTE To be able to handle exception only N as returnType is supported
+			LOG_ERROR("Only interface methods with a native int are supported. Found type '%c'", (char)dynType_descriptorType(returnType));
+			status = ERROR;
+		}
     }
 
     ffi_sarg returnVal = 1;


Mime
View raw message