Merge pull request #1601 from hokein/fix-out-of-bound
Fix a potential out-of-bound issue in Accelerator.
This commit is contained in:
commit
1571c3537d
1 changed files with 1 additions and 1 deletions
|
@ -175,7 +175,7 @@ bool StringToAccelerator(const std::string& description,
|
||||||
} else if (tokens[i].size() > 1 && tokens[i][0] == 'f') {
|
} else if (tokens[i].size() > 1 && tokens[i][0] == 'f') {
|
||||||
// F1 - F24.
|
// F1 - F24.
|
||||||
int n;
|
int n;
|
||||||
if (base::StringToInt(tokens[i].c_str() + 1, &n)) {
|
if (base::StringToInt(tokens[i].c_str() + 1, &n) && n > 0 && n < 25) {
|
||||||
key = static_cast<ui::KeyboardCode>(ui::VKEY_F1 + n - 1);
|
key = static_cast<ui::KeyboardCode>(ui::VKEY_F1 + n - 1);
|
||||||
} else {
|
} else {
|
||||||
LOG(WARNING) << tokens[i] << "is not available on keyboard";
|
LOG(WARNING) << tokens[i] << "is not available on keyboard";
|
||||||
|
|
Loading…
Reference in a new issue