diff options
author | Rich Felker <dalias@aerifal.cx> | 2006-10-06 01:35:42 +0000 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2006-10-06 01:35:42 +0000 |
commit | 28b12662b9815344c9abd7cd938e23921197e308 (patch) | |
tree | 37b79e98d77af36370ef281ae634cf446bb2482e | |
parent | f66fb2722d6bd53312f130c79fa06c7e40c57c39 (diff) |
fix out-of-bound memory write on first call (or after resize!)
-rw-r--r-- | dblbuf.c | 14 |
1 files changed, 7 insertions, 7 deletions
@@ -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) |