diff --git a/src/lib/internal.h b/src/lib/internal.h index 9959488b4..ce2ca6ce3 100644 --- a/src/lib/internal.h +++ b/src/lib/internal.h @@ -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); diff --git a/src/lib/visual.c b/src/lib/visual.c index 072bff4db..20a7d9feb 100644 --- a/src/lib/visual.c +++ b/src/lib/visual.c @@ -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;