You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@celix.apache.org by pe...@apache.org on 2023/04/10 10:51:24 UTC

[celix] 21/32: Fix Coverity 211229 Dereference after null check.

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 f38f570ac4c88119161bb0548e090e9a15bbfedc
Author: PengZheng <ho...@gmail.com>
AuthorDate: Mon Apr 10 17:19:39 2023 +0800

    Fix Coverity 211229 Dereference after null check.
---
 libs/framework/src/bundle_context.c | 22 +++++-----------------
 1 file changed, 5 insertions(+), 17 deletions(-)

diff --git a/libs/framework/src/bundle_context.c b/libs/framework/src/bundle_context.c
index d85e21cf..83f764a9 100644
--- a/libs/framework/src/bundle_context.c
+++ b/libs/framework/src/bundle_context.c
@@ -144,26 +144,14 @@ celix_status_t bundleContext_getFramework(bundle_context_pt context, framework_p
 }
 
 celix_status_t bundleContext_installBundle(bundle_context_pt context, const char * location, bundle_pt *bundle) {
-	return bundleContext_installBundle2(context, location, NULL, bundle);
+    return bundleContext_installBundle2(context, location, NULL, bundle);
 }
 
 celix_status_t bundleContext_installBundle2(bundle_context_pt context, const char *location, const char *inputFile, bundle_pt *bundle) {
-	celix_status_t status = CELIX_SUCCESS;
-	bundle_pt b = NULL;
-
-	if (context != NULL) {
-		if (celix_framework_installBundleInternal(context->framework, location, &b) != CELIX_SUCCESS) {
-            status = CELIX_FRAMEWORK_EXCEPTION;
-		} else {
-			*bundle = b;
-		}
-	} else {
-        status = CELIX_ILLEGAL_ARGUMENT;
-	}
-
-	framework_logIfError(context->framework->logger, status, NULL, "Failed to install bundle");
-
-	return status;
+    if (context == NULL || location == NULL || bundle == NULL) {
+        return CELIX_ILLEGAL_ARGUMENT;
+    }
+    return celix_framework_installBundleInternal(context->framework, location, bundle);
 }
 
 celix_status_t bundleContext_registerService(bundle_context_pt context, const char * serviceName, const void * svcObj,