Fix resizing strings to -1 length

Fixes #4042
This commit is contained in:
Maxime Coste 2021-02-01 20:16:06 +11:00
parent 5eb2be3e6b
commit 26cf5cd1dc

View File

@ -323,7 +323,7 @@ expand_token(const Token& token, const Context& context, const ShellContext& she
content, context, {}, ShellManager::Flags::WaitForStdout,
shell_context).first;
if (str.back() == '\n')
if (not str.empty() and str.back() == '\n')
str.resize(str.length() - 1, 0);
return {str};