You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@celix.apache.org by pn...@apache.org on 2015/09/23 16:22:34 UTC
[2/2] celix git commit: CELIX-237: Fixed small memory leak when
methods return not 0
CELIX-237: Fixed small memory leak when methods return not 0
Project: http://git-wip-us.apache.org/repos/asf/celix/repo
Commit: http://git-wip-us.apache.org/repos/asf/celix/commit/3f71ac4a
Tree: http://git-wip-us.apache.org/repos/asf/celix/tree/3f71ac4a
Diff: http://git-wip-us.apache.org/repos/asf/celix/diff/3f71ac4a
Branch: refs/heads/feature/CELIX-237_rsa-ffi
Commit: 3f71ac4a950bc8cca8542ecc770247089d7022bc
Parents: 8248c2c
Author: Pepijn Noltes <pe...@gmail.com>
Authored: Wed Sep 23 16:21:55 2015 +0200
Committer: Pepijn Noltes <pe...@gmail.com>
Committed: Wed Sep 23 16:21:55 2015 +0200
----------------------------------------------------------------------
.../dynamic_function_interface/json_rpc.c | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/celix/blob/3f71ac4a/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 d4c8f30..01dc6b5 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
@@ -124,13 +124,19 @@ int jsonRpc_call(dyn_interface_type *intf, void *service, const char *request, c
}
json_t *jsonResult = NULL;
+ for(i = 0; i < nrOfArgs; i += 1) {
+ dyn_type *argType = dynFunction_argumentTypeForIndex(func, i);
+ enum dyn_function_argument_meta meta = dynFunction_argumentMetaForIndex(func, i);
+ if (meta == DYN_FUNCTION_ARGUMENT_META__STD) {
+ //TODO SOMETIMES segfault dynType_free(argType, args[i]);
+ }
+ }
+
if (funcCallStatus == 0 && status == OK) {
for (i = 0; i < nrOfArgs; i += 1) {
dyn_type *argType = dynFunction_argumentTypeForIndex(func, i);
enum dyn_function_argument_meta meta = dynFunction_argumentMetaForIndex(func, i);
- if (meta == DYN_FUNCTION_ARGUMENT_META__STD) {
- dynType_free(argType, args[i]);
- } else if (meta == DYN_FUNCTION_ARGUMENT_META__PRE_ALLOCATED_OUTPUT) {
+ if (meta == DYN_FUNCTION_ARGUMENT_META__PRE_ALLOCATED_OUTPUT) {
if (status == OK) {
status = jsonSerializer_serializeJson(argType, args[i], &jsonResult);
}
@@ -162,8 +168,12 @@ int jsonRpc_call(dyn_interface_type *intf, void *service, const char *request, c
LOG_DEBUG("creating payload\n");
json_t *payload = json_object();
if (funcCallStatus == 0) {
- LOG_DEBUG("Setting result payload");
- json_object_set_new(payload, "r", jsonResult);
+ if (jsonResult == NULL) {
+ //ignore -> no result
+ } else {
+ LOG_DEBUG("Setting result payload");
+ json_object_set_new(payload, "r", jsonResult);
+ }
} else {
LOG_DEBUG("Setting error payload");
json_object_set_new(payload, "e", json_integer(funcCallStatus));