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 2016/01/25 19:01:59 UTC

[43/51] celix git commit: CELIX-341: fix possible dereferencing error

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 <bp...@apache.org>
Authored: Wed Jan 20 18:31:39 2016 +0100
Committer: Bjoern Petri <bp...@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;
 }