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 444c1b0c919da2acde4e41aa44d9864771bc68a8 Author: PengZheng <[email protected]> AuthorDate: Mon Apr 10 17:02:10 2023 +0800 Fix Coverity 211205 Dereference after null check. --- libs/framework/src/bundle_context.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/libs/framework/src/bundle_context.c b/libs/framework/src/bundle_context.c index 560868d9..91fb52cf 100644 --- a/libs/framework/src/bundle_context.c +++ b/libs/framework/src/bundle_context.c @@ -168,20 +168,11 @@ celix_status_t bundleContext_installBundle2(bundle_context_pt context, const cha celix_status_t bundleContext_registerService(bundle_context_pt context, const char * serviceName, const void * svcObj, properties_pt properties, service_registration_pt *service_registration) { - service_registration_pt registration = NULL; - celix_status_t status = CELIX_SUCCESS; - - if (context != NULL) { - long bndId = celix_bundle_getId(context->bundle); - fw_registerService(context->framework, ®istration, bndId, serviceName, svcObj, properties); - *service_registration = registration; - } else { - status = CELIX_ILLEGAL_ARGUMENT; - } - - framework_logIfError(context->framework->logger, status, NULL, "Failed to register service. serviceName '%s'", serviceName); - - return status; + if (context == NULL || service_registration == NULL) { + return CELIX_ILLEGAL_ARGUMENT; + } + long bndId = celix_bundle_getId(context->bundle); + return fw_registerService(context->framework, service_registration, bndId, serviceName, svcObj, properties); } celix_status_t bundleContext_registerServiceFactory(bundle_context_pt context, const char * serviceName, service_factory_pt factory,
