fix possible out of bound memory access

Origin commit data
------------------
Commit: 350a73ce08
Author: Jacek Jendrzej <overx300@gmail.com>
Date: 2017-08-23 (Wed, 23 Aug 2017)
This commit is contained in:
Jacek Jendrzej
2017-08-23 13:05:57 +02:00
parent 1e1d5ed137
commit 142d17c8b0

View File

@@ -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;count<validchar_len;count++)
if(valueString->at(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);