This is an automated email from the ASF dual-hosted git repository.

pengzheng pushed a commit to branch hotfix/coverity_fix
in repository https://gitbox.apache.org/repos/asf/celix.git

commit d538438d085dcd31445589117777b1117173c1bb
Author: PengZheng <[email protected]>
AuthorDate: Sun May 7 11:17:39 2023 +0800

    Fix Coverity 313622 Dereference after null check.
---
 bundles/shell/shell/src/c_shell_activator.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/bundles/shell/shell/src/c_shell_activator.c 
b/bundles/shell/shell/src/c_shell_activator.c
index 7d4db6b1..aa448432 100644
--- a/bundles/shell/shell/src/c_shell_activator.c
+++ b/bundles/shell/shell/src/c_shell_activator.c
@@ -73,7 +73,7 @@ celix_status_t 
celix_bundleActivator_create(celix_bundle_context_t* ctx, void **
 }
 
 celix_status_t celix_bundleActivator_start(void *activatorData, 
celix_bundle_context_t* ctx) {
-       celix_status_t status = CELIX_SUCCESS;
+    celix_status_t status = CELIX_SUCCESS;
 
     shell_bundle_activator_t* activator  = (shell_bundle_activator_t*) 
activatorData;
 
@@ -100,17 +100,17 @@ celix_status_t celix_bundleActivator_start(void 
*activatorData, celix_bundle_con
         activator->shellSvcId = 
celix_bundleContext_registerServiceWithOptions(ctx, &opts);
     }
 
-       if (status == CELIX_SUCCESS) {
-           celix_service_tracking_options_t opts = 
CELIX_EMPTY_SERVICE_TRACKING_OPTIONS;
-           opts.callbackHandle = activator->shell;
-           opts.addWithProperties = (void*) shell_addCommand;
-           opts.removeWithProperties = (void*) shell_removeCommand;
-           opts.filter.ignoreServiceLanguage = true;
-           opts.filter.serviceName = CELIX_SHELL_COMMAND_SERVICE_NAME;
-           activator->trackerId = 
celix_bundleContext_trackServicesWithOptions(ctx, &opts);
+    if (status == CELIX_SUCCESS) {
+        celix_service_tracking_options_t opts = 
CELIX_EMPTY_SERVICE_TRACKING_OPTIONS;
+        opts.callbackHandle = activator->shell;
+        opts.addWithProperties = (void*) shell_addCommand;
+        opts.removeWithProperties = (void*) shell_removeCommand;
+        opts.filter.ignoreServiceLanguage = true;
+        opts.filter.serviceName = CELIX_SHELL_COMMAND_SERVICE_NAME;
+        activator->trackerId = 
celix_bundleContext_trackServicesWithOptions(ctx, &opts);
+        activator->legacyTrackerId = -1L;
     }
 
-    activator->legacyTrackerId = -1L;
 #ifdef CELIX_INSTALL_DEPRECATED_API
     if (status == CELIX_SUCCESS) {
         celix_service_tracking_options_t opts = 
CELIX_EMPTY_SERVICE_TRACKING_OPTIONS;
@@ -123,7 +123,7 @@ celix_status_t celix_bundleActivator_start(void 
*activatorData, celix_bundle_con
     }
 #endif
 
-       return status;
+    return status;
 }
 
 celix_status_t celix_bundleActivator_stop(void *activatorData, 
celix_bundle_context_t* ctx) {

Reply via email to