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 775edb8add2ff10443e3c998b0c9a6f0bd9459a0 Author: PengZheng <[email protected]> AuthorDate: Mon Apr 10 18:49:37 2023 +0800 Fix Coverity 313587 Resource leak. --- libs/framework/src/bundle.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/libs/framework/src/bundle.c b/libs/framework/src/bundle.c index d23113d8..7f08f15e 100644 --- a/libs/framework/src/bundle.c +++ b/libs/framework/src/bundle.c @@ -207,7 +207,8 @@ celix_status_t bundle_createModule(bundle_pt bundle, module_pt* moduleOut) { const char * symName = NULL; - (void)module_getSymbolicName(module, &symName); // it always succeeds + status = module_getSymbolicName(module, &symName); + assert(status == CELIX_SUCCESS); /* * NOTE only allowing a single bundle with a symbolic name. * OSGi spec allows same symbolic name and different versions, but this is risky with @@ -217,11 +218,14 @@ celix_status_t bundle_createModule(bundle_pt bundle, module_pt* moduleOut) { if (alreadyInstalled) { status = CELIX_BUNDLE_EXCEPTION; fw_logCode(bundle->framework->logger, CELIX_LOG_LEVEL_ERROR, status, "Cannot create module, bundle with symbolic name '%s' already installed.", symName); - return status; + } + if (status == CELIX_SUCCESS) { + *moduleOut = module; + } else { + module_destroy(module); } - *moduleOut = module; - return status; + return status; } celix_status_t bundle_start(celix_bundle_t* bundle) {
