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 049857820273a82745d8b015ee343ab9919968c0 Author: PengZheng <[email protected]> AuthorDate: Mon Apr 10 16:20:51 2023 +0800 Fix Coverity 211175 Dereference after null check. --- libs/framework/src/bundle_context.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/libs/framework/src/bundle_context.c b/libs/framework/src/bundle_context.c index 0ed17594..26ff074c 100644 --- a/libs/framework/src/bundle_context.c +++ b/libs/framework/src/bundle_context.c @@ -265,17 +265,10 @@ FRAMEWORK_EXPORT celix_status_t bundleContext_retainServiceReference(bundle_cont } celix_status_t bundleContext_ungetServiceReference(bundle_context_pt context, service_reference_pt reference) { - celix_status_t status = CELIX_SUCCESS; - - if (context != NULL && reference != NULL && bundleContext_IsServiceReferenceValid(context, reference)) { - serviceReference_release(reference, NULL); - } 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_reference"); - - return status; + return serviceReference_release(reference, NULL); } celix_status_t bundleContext_getService(bundle_context_pt context, service_reference_pt reference, void** service_instance) {
