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 0b60ea476e47aa1b597df1b5703361ea3e2f5d2f
Author: PengZheng <[email protected]>
AuthorDate: Mon Apr 10 17:10:37 2023 +0800

    Fix Coverity 211208 Dereference after null check.
---
 libs/framework/src/bundle_context.c | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)

diff --git a/libs/framework/src/bundle_context.c 
b/libs/framework/src/bundle_context.c
index 91fb52cf..593cf502 100644
--- a/libs/framework/src/bundle_context.c
+++ b/libs/framework/src/bundle_context.c
@@ -279,20 +279,16 @@ celix_status_t bundleContext_getBundles(bundle_context_pt 
context, array_list_pt
 }
 
 celix_status_t bundleContext_getBundleById(bundle_context_pt context, long id, 
bundle_pt *bundle) {
+    if (context == NULL || bundle == NULL) {
+        return CELIX_ILLEGAL_ARGUMENT;
+    }
     celix_status_t status = CELIX_SUCCESS;
-
-    if (context == NULL || *bundle != NULL) {
-        status = CELIX_ILLEGAL_ARGUMENT;
-    } else {
-        *bundle = framework_getBundleById(context->framework, id);
-        if (*bundle == NULL) {
-            status = CELIX_BUNDLE_EXCEPTION;
-        }
+    *bundle = framework_getBundleById(context->framework, id);
+    if (*bundle == NULL) {
+        status = CELIX_BUNDLE_EXCEPTION;
     }
-
     framework_logIfError(context->framework->logger, status, NULL, "Failed to 
get bundle [id=%ld]", id);
-
-       return status;
+    return status;
 }
 
 celix_status_t bundleContext_addServiceListener(bundle_context_pt context, 
celix_service_listener_t *listener, const char* filter) {

Reply via email to