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 89c42c6cf71a3345912002d3e8f93a6ec0e4767e Author: PengZheng <[email protected]> AuthorDate: Mon Apr 10 15:31:46 2023 +0800 Fix Coverity 211168: dereference after null check. --- libs/framework/src/bundle_context.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/libs/framework/src/bundle_context.c b/libs/framework/src/bundle_context.c index be7bac8b..807febf5 100644 --- a/libs/framework/src/bundle_context.c +++ b/libs/framework/src/bundle_context.c @@ -343,17 +343,11 @@ celix_status_t bundleContext_getBundleById(bundle_context_pt context, long id, b } celix_status_t bundleContext_addServiceListener(bundle_context_pt context, celix_service_listener_t *listener, const char* filter) { - celix_status_t status = CELIX_SUCCESS; - - if (context != NULL && listener != NULL) { - fw_addServiceListener(context->framework, context->bundle, listener, filter); - } else { - status = CELIX_ILLEGAL_ARGUMENT; + if (context == NULL || listener == NULL) { + return CELIX_ILLEGAL_ARGUMENT; } - - framework_logIfError(context->framework->logger, status, NULL, "Failed to add service listener"); - - return status; + fw_addServiceListener(context->framework, context->bundle, listener, filter); + return CELIX_SUCCESS; } celix_status_t bundleContext_removeServiceListener(bundle_context_pt context, celix_service_listener_t *listener) {
