summaryrefslogtreecommitdiff
path: root/dblbuf.c
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2006-10-06 01:35:42 +0000
committerRich Felker <dalias@aerifal.cx>2006-10-06 01:35:42 +0000
commit28b12662b9815344c9abd7cd938e23921197e308 (patch)
tree37b79e98d77af36370ef281ae634cf446bb2482e /dblbuf.c
parentf66fb2722d6bd53312f130c79fa06c7e40c57c39 (diff)
downloaduuterm-28b12662b9815344c9abd7cd938e23921197e308.tar.gz
fix out-of-bound memory write on first call (or after resize!)
Diffstat (limited to 'dblbuf.c')
-rw-r--r--dblbuf.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/dblbuf.c b/dblbuf.c
index f53f3b8..79059f7 100644
--- a/dblbuf.c
+++ b/dblbuf.c
@@ -125,16 +125,17 @@ void uudisp_refresh(struct uudisp *d, struct uuterm *t)
{
struct dblbuf *b = (void *)&d->priv;
int h = t->h < d->h ? t->h : d->h;
- int y;
+ int x1, x2, idx, y;
/* Clean up cursor first.. */
- blit_slice(d, t->rows[b->curs_y]->idx, b->curs_x, b->curs_x);
- //printf("--- %d\r\n", b->slices[t->rows[b->curs_y]->idx].y);
+ idx = t->rows[b->curs_y]->idx;
+ if ((unsigned)b->slices[idx].y < d->h)
+ blit_slice(d, idx, b->curs_x, b->curs_x);
for (y=0; y<h; y++) {
- int idx = t->rows[y]->idx;
- int x1 = t->rows[y]->x1;
- int x2 = t->rows[y]->x2;
+ x1 = t->rows[y]->x1;
+ x2 = t->rows[y]->x2;
+ idx = t->rows[y]->idx;
if (x2 >= x1) {
clear_cells(d, idx, x1, x2);
uuterm_refresh_row(d, t->rows[y], x1, x2);
@@ -158,7 +159,6 @@ void uudisp_refresh(struct uudisp *d, struct uuterm *t)
}
b->curs_x = t->x;
b->curs_y = t->y;
- //printf("+++ %d\r\n", b->slices[t->rows[b->curs_y]->idx].y);
}
struct slice *dblbuf_setup_buf(int w, int h, int cs, int ch, unsigned char *mem)