summaryrefslogtreecommitdiff
path: root/src/managers/input/TextInput.cpp
diff options
context:
space:
mode:
authorVaxry <vaxry@vaxry.net>2026-01-05 16:25:46 +0100
committerVaxry <43317083+vaxerski@users.noreply.github.com>2026-01-05 18:53:29 +0100
commit8eb3ecc7556e07ffdb8037504429e9ccc749c0ab (patch)
treee2be9d682603d3949f2792167299fb5b01e772bf /src/managers/input/TextInput.cpp
parent97c8a2f1cf6da68ead76ea114e435b47026fd6a4 (diff)
input/TI: avoid UAF in destroy
Diffstat (limited to 'src/managers/input/TextInput.cpp')
-rw-r--r--src/managers/input/TextInput.cpp26
1 files changed, 12 insertions, 14 deletions
diff --git a/src/managers/input/TextInput.cpp b/src/managers/input/TextInput.cpp
index 40420129..be9a5d29 100644
--- a/src/managers/input/TextInput.cpp
+++ b/src/managers/input/TextInput.cpp
@@ -22,13 +22,7 @@ void CTextInput::initCallbacks() {
m_listeners.disable = INPUT->m_events.disable.listen([this] { onDisabled(); });
m_listeners.commit = INPUT->m_events.onCommit.listen([this] { onCommit(); });
m_listeners.reset = INPUT->m_events.reset.listen([this] { onReset(); });
- m_listeners.destroy = INPUT->m_events.destroy.listen([this] {
- m_listeners.surfaceUnmap.reset();
- m_listeners.surfaceDestroy.reset();
- g_pInputManager->m_relay.removeTextInput(this);
- if (!g_pInputManager->m_relay.getFocusedTextInput())
- g_pInputManager->m_relay.deactivateIME(this);
- });
+ m_listeners.destroy = INPUT->m_events.destroy.listen([this] { destroy(); });
if (Desktop::focusState()->surface() && Desktop::focusState()->surface()->client() == INPUT->client())
enter(Desktop::focusState()->surface());
@@ -39,16 +33,20 @@ void CTextInput::initCallbacks() {
m_listeners.disable = INPUT->m_events.disable.listen([this] { onDisabled(); });
m_listeners.commit = INPUT->m_events.onCommit.listen([this] { onCommit(); });
m_listeners.reset = INPUT->m_events.reset.listen([this] { onReset(); });
- m_listeners.destroy = INPUT->m_events.destroy.listen([this] {
- m_listeners.surfaceUnmap.reset();
- m_listeners.surfaceDestroy.reset();
- g_pInputManager->m_relay.removeTextInput(this);
- if (!g_pInputManager->m_relay.getFocusedTextInput())
- g_pInputManager->m_relay.deactivateIME(this);
- });
+ m_listeners.destroy = INPUT->m_events.destroy.listen([this] { destroy(); });
}
}
+void CTextInput::destroy() {
+ m_listeners.surfaceUnmap.reset();
+ m_listeners.surfaceDestroy.reset();
+
+ g_pInputManager->m_relay.removeTextInput(this);
+
+ if (!g_pInputManager->m_relay.getFocusedTextInput())
+ g_pInputManager->m_relay.deactivateIME(nullptr, false);
+}
+
void CTextInput::onEnabled(SP<CWLSurfaceResource> surfV1) {
Log::logger->log(Log::DEBUG, "TI ENABLE");