From 68d4d7d10a488b4c4f7b441c9660a2f2b9438b83 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sun, 21 Jun 2020 17:11:24 -0400 Subject: [PATCH] Ensures no out-of-bounds access for unlabelled keys. --- OSBindings/Qt/mainwindow.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/OSBindings/Qt/mainwindow.cpp b/OSBindings/Qt/mainwindow.cpp index c6b391414..03eec545c 100644 --- a/OSBindings/Qt/mainwindow.cpp +++ b/OSBindings/Qt/mainwindow.cpp @@ -104,8 +104,7 @@ void MainWindow::newFile() { other->show(); } -void MainWindow::tile(const QMainWindow *previous) -{ +void MainWindow::tile(const QMainWindow *previous) { // This entire function is essentially verbatim from the Qt SDI example. if (!previous) return; @@ -457,7 +456,7 @@ bool MainWindow::processEvent(QKeyEvent *event) { } std::unique_lock lock(machineMutex); - keyboardMachine->get_keyboard().set_key_pressed(key, event->text()[0].toLatin1(), event->type() == QEvent::KeyPress); + keyboardMachine->get_keyboard().set_key_pressed(key, event->text().size() ? event->text()[0].toLatin1() : '\0', event->type() == QEvent::KeyPress); return false; }