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 81ab2177a26bebe72738ac957e774837e3178634 Author: PengZheng <[email protected]> AuthorDate: Mon Apr 10 17:22:08 2023 +0800 Fix Coverity 211235 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 83f764a9..a0a8d436 100644 --- a/libs/framework/src/bundle_context.c +++ b/libs/framework/src/bundle_context.c @@ -215,17 +215,10 @@ static bool bundleContext_IsServiceReferenceValid(bundle_context_pt context, ser } FRAMEWORK_EXPORT celix_status_t bundleContext_retainServiceReference(bundle_context_pt context, service_reference_pt ref) { - celix_status_t status = CELIX_SUCCESS; - - if (context != NULL && ref != NULL && bundleContext_IsServiceReferenceValid(context, ref)) { - serviceReference_retain(ref); - } else { - status = CELIX_ILLEGAL_ARGUMENT; + if (context == NULL || ref == NULL || !bundleContext_IsServiceReferenceValid(context, ref)) { + return CELIX_ILLEGAL_ARGUMENT; } - - framework_logIfError(context->framework->logger, status, NULL, "Failed to retain service references"); - - return status; + return serviceReference_retain(ref); } celix_status_t bundleContext_ungetServiceReference(bundle_context_pt context, service_reference_pt reference) {
