Skip to content

Commit

Permalink
Fix another bounds-checking bug
Browse files Browse the repository at this point in the history
  • Loading branch information
newsch committed May 28, 2019
1 parent 6a46bf1 commit 8e3eaa6
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/frontend.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8e3eaa6

Please sign in to comment.