From 241a739dc27216dd39a61c5572932b68d2c6c8bb Mon Sep 17 00:00:00 2001 From: "Michael Cook (mackal)" <277429+mackal@users.noreply.github.com> Date: Mon, 3 Apr 2023 10:43:49 -0400 Subject: [PATCH] DolphinQt: RenderWidget fix heap-use-after-free The QByteArray returned by QString::toUtf8() was being freed so the char pointer was pointing to freed memory. Found via ASan, didn't notice any issues during normal runtime. This was triggered after hitting a key combo with alt (ex. toggle fullscreen) probably happens with others --- Source/Core/DolphinQt/RenderWidget.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Source/Core/DolphinQt/RenderWidget.cpp b/Source/Core/DolphinQt/RenderWidget.cpp index c39621ad73..8393434530 100644 --- a/Source/Core/DolphinQt/RenderWidget.cpp +++ b/Source/Core/DolphinQt/RenderWidget.cpp @@ -488,10 +488,11 @@ void RenderWidget::PassEventToPresenter(const QEvent* event) const u32 key = static_cast(key_event->key() & 0x1FF); const char* chars = nullptr; + QByteArray utf8; if (is_down) { - auto utf8 = key_event->text().toUtf8(); + utf8 = key_event->text().toUtf8(); if (utf8.size()) chars = utf8.constData();