From 6af01c8d519877905e353cf306ddd5df77f9be96 Mon Sep 17 00:00:00 2001 From: Evan New-Schmidt Date: Mon, 27 May 2019 17:03:04 -0700 Subject: [PATCH] Fix another bounds-checking bug --- src/frontend.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/frontend.c b/src/frontend.c index baf0bea..9e9b1cc 100644 --- a/src/frontend.c +++ b/src/frontend.c @@ -370,10 +370,11 @@ void redraw_canvas_win() { */ void draw_collab_cursors(collab_list_t *collab_list) { collab_t *c = NULL; + // calculate visible bounds (in canvas coordinates) const int min_x = view->x; const int min_y = view->y; - const int max_x = min(view_max_x, view->canvas->num_cols - view->x); - const int max_y = min(view_max_y, view->canvas->num_rows - view->y); + const int max_x = min(view->canvas->num_cols, view->x + view_max_x) - 1; + const int max_y = min(view->canvas->num_rows, view->y + view_max_y) - 1; for (int i = 0; i < collab_list->len; i++) { c = collab_list->list[i]; // only draw cursors that exist and are visible on the screen