Fix crash in tab completion if one command is a prefix of another.

svn-id: r42597
This commit is contained in:
Willem Jan Palenstijn 2009-07-18 22:17:56 +00:00
parent d362ca86f6
commit 66b565c9c2

View file

@ -307,7 +307,8 @@ bool Debugger::tabComplete(const char *input, Common::String &completion) const
} else {
// take common prefix of previous match and this command
for (uint j = 0; j < completion.size(); j++) {
if (completion[j] != i->_key[inputlen + j]) {
if (inputlen + j >= i->_key.size() ||
completion[j] != i->_key[inputlen + j]) {
completion = Common::String(completion.begin(), completion.begin() + j);
// If there is no unambiguous completion, abort
if (completion.empty())