celix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pnol...@apache.org
Subject [43/51] celix git commit: CELIX-341: fix possible dereferencing error
Date Mon, 25 Jan 2016 18:01:59 GMT
CELIX-341: fix possible dereferencing error


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

Branch: refs/heads/feature/CELIX-335_deploy_refactoring
Commit: 38fd461116e545847924c44983c7a1cc8e440c77
Parents: fa4ee3c
Author: Bjoern Petri <bpetri@apache.org>
Authored: Wed Jan 20 18:31:39 2016 +0100
Committer: Bjoern Petri <bpetri@apache.org>
Committed: Wed Jan 20 18:31:39 2016 +0100

----------------------------------------------------------------------
 shell/private/src/activator.c | 34 +++++++++++++++++++---------------
 1 file changed, 19 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/celix/blob/38fd4611/shell/private/src/activator.c
----------------------------------------------------------------------
diff --git a/shell/private/src/activator.c b/shell/private/src/activator.c
index edd2931..69f656f 100644
--- a/shell/private/src/activator.c
+++ b/shell/private/src/activator.c
@@ -237,10 +237,10 @@ celix_status_t bundleActivator_start(void *_ptr, bundle_context_pt context_ptr)
 }
 
 celix_status_t bundleActivator_stop(void *_ptr, bundle_context_pt context_ptr) {
-	celix_status_t status = CELIX_SUCCESS;
+    celix_status_t status = CELIX_SUCCESS;
     celix_status_t sub_status;
 
-	bundle_instance_pt instance_ptr = (bundle_instance_pt) _ptr;
+    bundle_instance_pt instance_ptr = (bundle_instance_pt) _ptr;
 
     if (instance_ptr) {
         for (unsigned int i = 0; instance_ptr->std_commands[i].exec != NULL; i++) {
@@ -250,32 +250,36 @@ celix_status_t bundleActivator_stop(void *_ptr, bundle_context_pt context_ptr)
{
                 instance_ptr->std_commands[i].props = NULL;
             }
         }
-    }
 
-	sub_status = bundleContext_removeServiceListener(context_ptr, instance_ptr->listener);
-    if (status == CELIX_SUCCESS && sub_status != CELIX_SUCCESS) {
-        status = sub_status;
+        sub_status = bundleContext_removeServiceListener(context_ptr, instance_ptr->listener);
+        if (status == CELIX_SUCCESS && sub_status != CELIX_SUCCESS) {
+            status = sub_status;
+        }
+    } else {
+        status = CELIX_ILLEGAL_ARGUMENT;
     }
 
-	return status;
+    return status;
 }
 
 celix_status_t bundleActivator_destroy(void *_ptr, bundle_context_pt __attribute__((__unused__))
context_ptr) {
+    celix_status_t status = CELIX_SUCCESS;
+
     bundle_instance_pt instance_ptr = (bundle_instance_pt) _ptr;
 
     if (instance_ptr) {
         for (unsigned int i = 0; instance_ptr->std_commands[i].exec != NULL; i++) {
             free(instance_ptr->std_commands[i].service);
         }
-    }
-
-    serviceRegistration_unregister(instance_ptr->registration);
 
-    shell_destroy(&instance_ptr->shellService);
+        serviceRegistration_unregister(instance_ptr->registration);
+        shell_destroy(&instance_ptr->shellService);
 
-    free(instance_ptr->listener);
-
-    free(instance_ptr);
+        free(instance_ptr->listener);
+        free(instance_ptr);
+    } else {
+        status = CELIX_ILLEGAL_ARGUMENT;
+    }
 
-	return CELIX_SUCCESS;
+    return status;
 }


Mime
View raw message