ncvisual_render_pixels: reject negative placex/placey on alignment #1526

pull/1535/head
nick black 3 years ago
parent 669bc5fa33
commit cfd47c26b6
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC

@ -1252,6 +1252,8 @@ plane_blit_sixel(sprixel* spx, char* s, int bytes, int rows, int cols,
}
ncplane* n = spx->n;
uint32_t gcluster = htole(0x02000000ul) + htole(spx->id);
// FIXME rows/cols ought never exceed the size, just as placey/placex
// ought never be negative. why need we check the former?
for(int y = placey ; y < placey + rows && y < ncplane_dim_y(n) ; ++y){
for(int x = placex ; x < placex + cols && x < ncplane_dim_x(n) ; ++x){
nccell* c = ncplane_cell_ref_yx(n, y, x);

@ -652,6 +652,9 @@ ncplane* ncvisual_render_pixels(notcurses* nc, ncvisual* ncv, const struct blits
}else if(placex == NCALIGN_RIGHT){
placex = ncplane_dim_x(n) - dispcols / nc->tcache.cellpixx;
}
if(placex < 0){
return NULL;
}
}
if(flags & NCVISUAL_OPTION_VERALIGNED){
if(placey == NCALIGN_CENTER){
@ -659,6 +662,9 @@ ncplane* ncvisual_render_pixels(notcurses* nc, ncvisual* ncv, const struct blits
}else if(placey == NCALIGN_BOTTOM){
placey = ncplane_dim_y(n) * nc->tcache.cellpixy - disprows / nc->tcache.cellpixy;
}
if(placey < 0){
return NULL;
}
}
//fprintf(stderr, "pblit: %dx%d <- %dx%d of %d/%d stride %u @%dx%d %p %u\n", disprows, dispcols, begy, begx, ncv->rows, ncv->cols, ncv->rowstride, placey, placex, ncv->data, nc->tcache.cellpixx);
blitterargs bargs;

Loading…
Cancel
Save