reader: Fix crash when text is empty after stripping spaces

This crashed on Fedora with the rpm packages, but not when building
from source, so some compiler option triggers it.

But the root cause is us running `text.front()` on an empty string,
which isn't something you should do.

Fixes #8009.
This commit is contained in:
Fabian Homborg 2021-05-16 22:13:32 +02:00
parent 31f3c16857
commit a427bf207a

View File

@ -3274,9 +3274,8 @@ void reader_data_t::handle_readline_command(readline_cmd_t c, readline_loop_stat
text.pop_back();
}
if (history && !conf.in_silent_mode) {
if (!text.empty() && history && !conf.in_silent_mode) {
// Remove ephemeral items.
// Note we fall into this case if the user just types a space and hits return.
history->remove_ephemeral_items();
// Mark this item as ephemeral if there is a leading space (#615).