From a07fb98347a8bba47b099ed24aff7aec8fe754aa Mon Sep 17 00:00:00 2001 From: Bobby Bingham Date: Mon, 24 Aug 2015 22:22:45 -0500 Subject: fix crash when window is resized smaller If the cursor was being displayed and its previous position is now outside the resized window, we could crash when trying to erase the old cursor. --- xlib.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/xlib.c b/xlib.c index a94e8f8..33e819a 100644 --- a/xlib.c +++ b/xlib.c @@ -401,14 +401,17 @@ static void blit_slice(struct uudisp *d, int idx, int x1, int x2) void uudisp_refresh(struct uudisp *d, struct uuterm *t) { struct priv *p = (void *)&d->priv; + int w = t->w < d->w ? t->w : d->w; int h = t->h < d->h ? t->h : d->h; int x1, x2, idx, y; /* Clean up cursor first.. */ if (p->curs_on && (!d->blink || t->x != p->curs_x || t->y != p->curs_y)) { - idx = t->rows[p->curs_y]->idx; - if ((unsigned)p->slices_y[idx] < d->h) - blit_slice(d, idx, p->curs_x, p->curs_x); + if (p->curs_x < w && p->curs_y < h) { + idx = t->rows[p->curs_y]->idx; + if ((unsigned)p->slices_y[idx] < d->h) + blit_slice(d, idx, p->curs_x, p->curs_x); + } p->curs_on = 0; } -- cgit v1.2.3