screen: Avoid crash if clr_eol is undefined

This crashes if the terminfo entry does not have the el capability.
Which is unusual but happens with the (outdated) "terminology" entry.

Fixes #5371.
This commit is contained in:
Fabian Homborg 2018-11-28 13:08:48 +01:00
parent 047fcb3224
commit d91b48b866

View File

@ -759,7 +759,7 @@ static void s_update(screen_t *scr, const wcstring &left_prompt, const wcstring
s_line.text.empty() ? 0 : fish_wcswidth(&s_line.text.at(0), s_line.text.size());
clear_remainder = prev_width > current_width;
}
if (clear_remainder) {
if (clear_remainder && clr_eol) {
s_set_color(scr, &output, 0xffffffff);
s_move(scr, &output, current_width, (int)i);
s_write_mbs(&output, clr_eol);
@ -788,7 +788,7 @@ static void s_update(screen_t *scr, const wcstring &left_prompt, const wcstring
}
// Clear remaining lines (if any) if we haven't cleared the screen.
if (!has_cleared_screen && scr->desired.line_count() < lines_with_stuff) {
if (!has_cleared_screen && scr->desired.line_count() < lines_with_stuff && clr_eol) {
s_set_color(scr, &output, 0xffffffff);
for (size_t i = scr->desired.line_count(); i < lines_with_stuff; i++) {
s_move(scr, &output, 0, (int)i);
@ -1196,7 +1196,7 @@ void s_reset(screen_t *s, screen_reset_mode_t mode) {
// line above your prompt. This doesn't make a difference in normal usage, but copying and
// pasting your terminal log becomes a pain. This commit clears that line, making it an
// actual empty line.
if (!is_dumb()) {
if (!is_dumb() && clr_eol) {
abandon_line_string.append(str2wcstring(clr_eol));
}