avoid segfault on the last word of the command history

This commit is contained in:
Axel Kohlmeyer
2020-10-11 14:05:37 -04:00
parent 9950f0d259
commit f6683fefea

View File

@ -229,7 +229,8 @@ static char *cmd_generator(const char *text, int state)
len = strlen(text);
do {
if ((len == 0) || (commands[idx].substr(0, len) == text))
if ((idx < commands.size())
&& ((len == 0) || (commands[idx].substr(0, len) == text)))
return dupstring(commands[idx++]);
else
++idx;