diff --git a/src/complete.cpp b/src/complete.cpp index 3b3e8ef0b..653157887 100644 --- a/src/complete.cpp +++ b/src/complete.cpp @@ -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; }