From 142d17c8b080c8ea89ae9cbb4ffbfb1dc4623f5d Mon Sep 17 00:00:00 2001 From: Jacek Jendrzej Date: Wed, 23 Aug 2017 13:05:57 +0200 Subject: [PATCH] fix possible out of bound memory access Origin commit data ------------------ Commit: https://github.com/neutrino-images/ni-neutrino/commit/350a73ce08dee05dfc80e5f35bffb38bbeec877f Author: Jacek Jendrzej Date: 2017-08-23 (Wed, 23 Aug 2017) --- src/gui/widget/stringinput.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/gui/widget/stringinput.cpp b/src/gui/widget/stringinput.cpp index f325cedb1..a0c789a86 100644 --- a/src/gui/widget/stringinput.cpp +++ b/src/gui/widget/stringinput.cpp @@ -278,12 +278,17 @@ void CStringInput::keyDownPressed() { int npos = 0; std::string tmp_value = *valueString; - for(int count=0;count<(int)strlen(validchars);count++) + const int validchar_len = (int)strlen(validchars); + for(int count=0;countat(selected)==validchars[count]) npos = count; npos--; - if(npos<0) - npos = strlen(validchars)-1; + if(npos<0){ + if(validchar_len > 0) + npos = validchar_len-1; + else + npos = 0; + } valueString->at(selected)=validchars[npos]; int current_value = atoi(*valueString);