summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBobby Bingham <koorogi@koorogi.info>2015-08-24 22:22:45 -0500
committerBobby Bingham <koorogi@koorogi.info>2015-08-29 13:06:49 -0500
commita07fb98347a8bba47b099ed24aff7aec8fe754aa (patch)
tree4c221715bdcc848f09ff877529a656b32230c65b
parent03af1408410e3e1ab0952e1fab6d7acf94b014ef (diff)
fix crash when window is resized smallerHEADmaster
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.
-rw-r--r--xlib.c9
1 files 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;
}