This is an automated email from the ASF dual-hosted git repository.
pengzheng pushed a commit to branch hotfix/use-after-free
in repository https://gitbox.apache.org/repos/asf/celix.git
The following commit(s) were added to refs/heads/hotfix/use-after-free by this
push:
new abcd53c0 Fix possible use-after-free.
abcd53c0 is described below
commit abcd53c0120f1a1b9c065c54cd7400b0d19de054
Author: PengZheng <[email protected]>
AuthorDate: Thu Jul 7 20:14:34 2022 +0800
Fix possible use-after-free.
Suppose that we allocate memory in actStart to implement a service, which
is managed by dm, and that in actStop we deallocate it, we must first stop the
dm from using the service before deallocation happens.
---
libs/framework/include/celix_bundle_activator.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/libs/framework/include/celix_bundle_activator.h
b/libs/framework/include/celix_bundle_activator.h
index 19dc1770..30f82579 100644
--- a/libs/framework/include/celix_bundle_activator.h
+++ b/libs/framework/include/celix_bundle_activator.h
@@ -149,12 +149,12 @@ celix_status_t celix_bundleActivator_start(void
*userData, celix_bundle_context_
\
celix_status_t celix_bundleActivator_stop(void *userData,
celix_bundle_context_t *ctx) { \
celix_status_t status = CELIX_SUCCESS;
\
+ celix_dependency_manager_t* mng =
celix_bundleContext_getDependencyManager(ctx);
\
+ celix_dependencyManager_removeAllComponents(mng);
\
celix_status_t (*fn)(actType*, celix_bundle_context_t*) = (actStop);
\
if (fn != NULL) {
\
status = fn((actType*)userData, ctx);
\
}
\
- celix_dependency_manager_t* mng =
celix_bundleContext_getDependencyManager(ctx);
\
- celix_dependencyManager_removeAllComponents(mng);
\
return status;
\
}
\
\