From c77b60c91073471c0910c40b4df2baa08e01fa9b Mon Sep 17 00:00:00 2001 From: Vaxry Date: Sat, 4 May 2024 16:37:26 +0100 Subject: [PATCH] keyboard: prevent UAF in destroy events --- src/devices/Keyboard.cpp | 2 +- src/devices/VirtualKeyboard.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/devices/Keyboard.cpp b/src/devices/Keyboard.cpp index 11257a74..17357edb 100644 --- a/src/devices/Keyboard.cpp +++ b/src/devices/Keyboard.cpp @@ -23,9 +23,9 @@ CKeyboard::CKeyboard(wlr_keyboard* keeb) : keyboard(keeb) { // clang-format off hyprListener_destroy.initCallback(&keeb->base.events.destroy, [this] (void* owner, void* data) { - events.destroy.emit(); disconnectCallbacks(); keyboard = nullptr; + events.destroy.emit(); }, this, "CKeyboard"); hyprListener_key.initCallback(&keeb->events.key, [this] (void* owner, void* data) { diff --git a/src/devices/VirtualKeyboard.cpp b/src/devices/VirtualKeyboard.cpp index fa91ae9f..dfe3c6df 100644 --- a/src/devices/VirtualKeyboard.cpp +++ b/src/devices/VirtualKeyboard.cpp @@ -18,9 +18,9 @@ CVirtualKeyboard::CVirtualKeyboard(SP keeb_) : keybo // clang-format off hyprListener_destroy.initCallback(&keeb->base.events.destroy, [this] (void* owner, void* data) { - events.destroy.emit(); disconnectCallbacks(); keyboard.reset(); + events.destroy.emit(); }, this, "CVirtualKeyboard"); hyprListener_key.initCallback(&keeb->events.key, [this] (void* owner, void* data) {