From f885abb71bd30466b40a5c70203e1787082766b8 Mon Sep 17 00:00:00 2001 From: Fritz Mahnke Date: Mon, 17 Apr 2023 08:28:37 -0700 Subject: [PATCH] Don't index into empty QString in HexEditor. QKeyEvent::text may return an empty string in some environments for some keys, such as modifier keys. This can cause a cause a crash. Add a check for the hex editor to skip the editing code, which assumes the keyboard event is a printable character and depends on a non-empty keyboard event text. --- src/drivers/Qt/HexEditor.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/drivers/Qt/HexEditor.cpp b/src/drivers/Qt/HexEditor.cpp index 04f1365d..eda90bdf 100644 --- a/src/drivers/Qt/HexEditor.cpp +++ b/src/drivers/Qt/HexEditor.cpp @@ -2777,7 +2777,13 @@ void QHexEdit::keyPressEvent(QKeyEvent *event) event->accept(); } else - { + { // Use the input text to modify the values in the editor area. + + if (event->text().isEmpty()) + { + return; + } + int key; if ( cursorPosX >= 32 ) { // Edit Area is ASCII