This is an automated email from the ASF dual-hosted git repository.
pengzheng pushed a commit to branch feature/refactor_bundle_cache
in repository https://gitbox.apache.org/repos/asf/celix.git
The following commit(s) were added to refs/heads/feature/refactor_bundle_cache
by this push:
new 9e8ccec7 Fix corner case memory leak for
celix_bundleCache_createArchive.
9e8ccec7 is described below
commit 9e8ccec7251a1d2a56c4d5e0ded0b2181a3aef9b
Author: PengZheng <[email protected]>
AuthorDate: Fri Mar 17 15:24:02 2023 +0800
Fix corner case memory leak for celix_bundleCache_createArchive.
---
libs/framework/src/celix_bundle_cache.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/libs/framework/src/celix_bundle_cache.c
b/libs/framework/src/celix_bundle_cache.c
index 22bac390..ba3bcb2e 100644
--- a/libs/framework/src/celix_bundle_cache.c
+++ b/libs/framework/src/celix_bundle_cache.c
@@ -195,13 +195,12 @@ celix_status_t
celix_bundleCache_createArchive(celix_framework_t* fw, long id, c
celixThreadMutex_lock(&fw->cache->mutex);
status = bundleArchive_create(fw, archiveRoot, id, location,
&archive);
celixThreadMutex_unlock(&fw->cache->mutex);
- if (status != CELIX_SUCCESS) {
- celix_utils_freeStringIfNotEqual(archiveRootBuffer, archiveRoot);
- return status;
- }
} else {
status = CELIX_ENOMEM;
- fw_logCode(fw->logger, CELIX_LOG_LEVEL_ERROR, status, "Failed to
create archive. Out of memory.");
+ }
+ celix_utils_freeStringIfNotEqual(archiveRootBuffer, archiveRoot);
+ if (status != CELIX_SUCCESS) {
+ fw_logCode(fw->logger, CELIX_LOG_LEVEL_ERROR, status, "Failed to
create archive.");
return status;
}