Avoid UB in tmux/window_copy_add_formats()

Do not perform NULL pointer arithmetics.

Reported with MKSANITIZER/UBSan.

The patch proposed by upstream https://github.com/tmux/tmux/issues/1382
This commit is contained in:
kamil 2018-06-25 18:41:25 +00:00
parent 54b8bd3463
commit eb8a7705cd
1 changed files with 1 additions and 2 deletions

View File

@ -2418,12 +2418,11 @@ void
window_copy_add_formats(struct window_pane *wp, struct format_tree *ft)
{
struct window_copy_mode_data *data = wp->modedata;
struct screen *s = &data->screen;
if (wp->mode != &window_copy_mode)
return;
format_add(ft, "selection_present", "%d", s->sel.flag);
format_add(ft, "selection_present", "%d", data->screen.sel.flag);
format_add(ft, "scroll_position", "%d", data->oy);
}