This is an automated email from the ASF dual-hosted git repository.

pengzheng pushed a commit to branch hotfix/647-event-use-after-free
in repository https://gitbox.apache.org/repos/asf/celix.git

commit e98a6ec0942bc4c0ee660f68191bd300993565c1
Author: PengZheng <[email protected]>
AuthorDate: Fri Nov 3 14:36:09 2023 +0800

    #647: Fix use-after-free in celix_framework_scheduleEvent.
---
 libs/framework/src/framework.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/libs/framework/src/framework.c b/libs/framework/src/framework.c
index fc61a53b..812b7799 100644
--- a/libs/framework/src/framework.c
+++ b/libs/framework/src/framework.c
@@ -2531,21 +2531,22 @@ long celix_framework_scheduleEvent(celix_framework_t* 
fw,
         return -1L; //error logged by celix_scheduledEvent_create
     }
 
+    long id = celix_scheduledEvent_getId(event);
     fw_log(fw->logger,
            CELIX_LOG_LEVEL_DEBUG,
            "Added scheduled event '%s' (id=%li) for bundle '%s' (id=%li).",
            celix_scheduledEvent_getName(event),
-           celix_scheduledEvent_getId(event),
+           id,
            celix_bundle_getSymbolicName(bndEntry->bnd),
            bndId);
     celix_framework_bundleEntry_decreaseUseCount(bndEntry);
 
     celixThreadMutex_lock(&fw->dispatcher.mutex);
-    celix_longHashMap_put(fw->dispatcher.scheduledEvents, 
celix_scheduledEvent_getId(event), event);
+    celix_longHashMap_put(fw->dispatcher.scheduledEvents, id, event);
     celixThreadCondition_broadcast(&fw->dispatcher.cond); //notify dispatcher 
thread for newly added scheduled event
     celixThreadMutex_unlock(&fw->dispatcher.mutex);
 
-    return celix_scheduledEvent_getId(event);
+    return id;
 }
 
 celix_status_t celix_framework_wakeupScheduledEvent(celix_framework_t* fw, 
long scheduledEventId) {

Reply via email to