Fix off-by-one in complete_cmd_desc

The substring constructor (string(str, pos)) includes pos, so we need
to add one. Also be careful not to go over the length again.
This commit is contained in:
Fabian Homborg 2018-06-03 17:59:11 +02:00
parent ebc5e18956
commit 8de5af5f9e

View File

@ -545,7 +545,8 @@ void completer_t::complete_cmd_desc(const wcstring &str) {
wcstring cmd;
size_t pos = str.find_last_of(L'/');
if (pos != std::string::npos) {
cmd = wcstring(str, pos);
if (pos + 1 > str.length()) return;
cmd = wcstring(str, pos + 1);
} else {
cmd = str;
}