1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 18:17:44 +00:00

LibWeb: Fix crash when removing event listeners

This commit is contained in:
Jamie Mansfield 2022-03-20 20:17:57 +00:00 committed by Andreas Kling
parent 27eb70cbba
commit 9b9d32dfb2

View file

@ -163,9 +163,16 @@ void EventTarget::remove_event_listener(FlyString const& type, RefPtr<IDLEventLi
// 2. If thiss event listener list contains an event listener whose type is type, callback is callback, and capture is capture,
// then remove an event listener with this and that event listener.
auto callbacks_match = [&](NonnullRefPtr<DOMEventListener>& entry) {
if (entry->callback.is_null() && callback.is_null())
return true;
if (entry->callback.is_null() || callback.is_null())
return false;
return entry->callback->callback().callback.cell() == callback->callback().callback.cell();
};
auto it = m_event_listener_list.find_if([&](auto& entry) {
return entry->type == type
&& entry->callback->callback().callback.cell() == callback->callback().callback.cell()
&& callbacks_match(entry)
&& entry->capture == capture;
});
if (it != m_event_listener_list.end())