capi handleNodeEvent uaf bug fix

Signed-off-by: zhouchaobo <zhouchaobo@huawei.com>
Change-Id: Ie8c452489433f3056278466f85df557c3c04b563
This commit is contained in:
zhouchaobo 2024-08-08 16:05:25 +08:00
parent 812a63654d
commit 649d9b1c38
2 changed files with 21 additions and 5 deletions

View File

@ -532,17 +532,31 @@ void HandleNodeEvent(ArkUI_NodeEvent* event)
}
if (event->node && event->node->eventListeners) {
auto eventListenersSet = reinterpret_cast<std::set<void (*)(ArkUI_NodeEvent*)>*>(event->node->eventListeners);
if (eventListenersSet) {
for (const auto& eventListener : *eventListenersSet) {
(*eventListener)(event);
}
}
TriggerNodeEvent(event, eventListenersSet);
}
if (g_eventReceiver) {
g_eventReceiver(event);
}
}
void TriggerNodeEvent(ArkUI_NodeEvent* event, std::set<void (*)(ArkUI_NodeEvent*)>* eventListenersSet)
{
if (!eventListenersSet) {
return;
}
if (eventListenersSet->size() == 1) {
auto eventListener = eventListenersSet->begin();
(*eventListener)(event);
} else if (eventListenersSet->size() > 1) {
for (const auto& eventListener : *eventListenersSet) {
(*eventListener)(event);
if (!IsValidArkUINode(event->node)) {
break;
}
}
}
}
int32_t CheckEvent(ArkUI_NodeEvent* event)
{
return 0;

View File

@ -17,6 +17,7 @@
#define FOUNDATION_ACE_FRAMEWORKS_CORE_INTERFACES_NATIVE_NODE_NODE_MODEL_H
#include <cstdint>
#include <set>
#include <vector>
#include <string>
@ -145,6 +146,7 @@ int32_t CheckEvent(ArkUI_NodeEvent* event);
void HandleInnerNodeEvent(ArkUINodeEvent* innerEvent);
int32_t GetNativeNodeEventType(ArkUINodeEvent* innerEvent);
void HandleNodeEvent(ArkUI_NodeEvent* event);
void TriggerNodeEvent(ArkUI_NodeEvent* event, std::set<void (*)(ArkUI_NodeEvent*)>* eventListenersSet);
void ApplyModifierFinish(ArkUI_NodeHandle nodePtr);
void MarkDirty(ArkUI_NodeHandle nodePtr, ArkUI_NodeDirtyFlag dirtyFlag);