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
This commit is contained in:
Michael Cook (mackal) 2023-04-03 10:43:49 -04:00
parent 655fca3efe
commit 241a739dc2

View File

@ -488,10 +488,11 @@ void RenderWidget::PassEventToPresenter(const QEvent* event)
const u32 key = static_cast<u32>(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();