From 019e867d1099ad2c6501df9b1662595ea38eb0be Mon Sep 17 00:00:00 2001 From: Peter Hartmann Date: Wed, 12 Apr 2023 10:36:42 +0200 Subject: [PATCH] virtual keyboard: Fix out of bounds access The user can modify the keyboard rows and cols, so we should not rely on hardcoded values. --- src/inputpanel/QskVirtualKeyboard.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/inputpanel/QskVirtualKeyboard.cpp b/src/inputpanel/QskVirtualKeyboard.cpp index d396e6fe..74f8706a 100644 --- a/src/inputpanel/QskVirtualKeyboard.cpp +++ b/src/inputpanel/QskVirtualKeyboard.cpp @@ -434,9 +434,11 @@ void QskVirtualKeyboard::updateKeyCodes() m_data->keyCodes = {}; m_data->keyCodes.reserve( rowCount() * columnCount() ); - for ( int mode = 0; mode < ModeCount; mode++ ) + const auto layout = *m_data->currentLayout; + + for ( int mode = 0; mode < layout.size(); mode++ ) { - const auto& page = ( *m_data->currentLayout )[ mode ]; + const auto& page = layout[ mode ]; for ( int i = 0; i < page.size(); i++ ) {