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 a4048afa7f3b32a0bf19b78846a902e7ecadd6cb Author: PengZheng <[email protected]> AuthorDate: Mon Apr 10 16:26:40 2023 +0800 Fix Coverity 211183 Dereference after null check. --- libs/framework/src/bundle_context.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/libs/framework/src/bundle_context.c b/libs/framework/src/bundle_context.c index 42e12676..f1b3c534 100644 --- a/libs/framework/src/bundle_context.c +++ b/libs/framework/src/bundle_context.c @@ -286,15 +286,10 @@ celix_status_t bundleContext_getService(bundle_context_pt context, service_refer } celix_status_t bundleContext_ungetService(bundle_context_pt context, service_reference_pt reference, bool *result) { - celix_status_t status = CELIX_SUCCESS; - if (context != NULL && reference != NULL && bundleContext_IsServiceReferenceValid(context, reference)) { - status = serviceReference_ungetService(reference, result); - } else { - status = CELIX_ILLEGAL_ARGUMENT; + if (context == NULL || reference == NULL || !bundleContext_IsServiceReferenceValid(context, reference)) { + return CELIX_ILLEGAL_ARGUMENT; } - framework_logIfError(context->framework->logger, status, NULL, "Failed to unget service"); - - return status; + return serviceReference_ungetService(reference, result); } celix_status_t bundleContext_getBundles(bundle_context_pt context, array_list_pt *bundles) {
