diff --git a/src/conio/bitmap_con.c b/src/conio/bitmap_con.c index 38f0b812bf55879b9e18e26118c6cae96595ae94..fd8e5659516f5bf1b717882eb6325133f2bb2be4 100644 --- a/src/conio/bitmap_con.c +++ b/src/conio/bitmap_con.c @@ -273,8 +273,6 @@ bitmap_vmem_puttext_locked(int sx, int sy, int ex, int ey, struct vmem_cell *fil || sy < 1 || ex < 1 || ey < 1 - || sx > cio_textinfo.screenwidth - || sy > cio_textinfo.screenheight || sx > ex || sy > ey || ex > cio_textinfo.screenwidth @@ -882,17 +880,29 @@ static int update_from_vmem(int force) /**********************/ int bitmap_puttext(int sx, int sy, int ex, int ey, void *fill) { - int x, y; + size_t x, y; int ret = 1; uint16_t *buf = fill; struct vstat_vmem *vmem_ptr; struct vmem_cell *vc; + if (sx < 1 + || sy < 1 + || ex < 1 + || ey < 1 + || sx > ex + || sy > ey + || ex > cio_textinfo.screenwidth + || ey > cio_textinfo.screenheight + || fill==NULL) { + return(0); + } + pthread_mutex_lock(&vstatlock); vmem_ptr = get_vmem(&vstat); - for(y=sy-1;y<ey;y++) { - for(x=sx-1;x<ex;x++) { - vc = set_vmem_cell(vmem_ptr, y*cio_textinfo.screenwidth+x, *(buf++), 0x00ffffff, 0x00ffffff); + for (y = sy - 1; y < ey; y++) { + for (x = sx - 1; x < ex; x++) { + vc = set_vmem_cell(vmem_ptr, y * cio_textinfo.screenwidth + x, *(buf++), 0x00ffffff, 0x00ffffff); bitmap_draw_one_char(vc, x+1, y+1); } } @@ -1264,8 +1274,8 @@ void bitmap_clreol(void) void bitmap_clrscr(void) { - int x,y; - WORD fill=(cio_textinfo.attribute<<8)|' '; + size_t x, y; + WORD fill = (cio_textinfo.attribute << 8) | ' '; struct vstat_vmem *vmem_ptr; struct vmem_cell *vc; int rows, cols; @@ -1274,9 +1284,9 @@ void bitmap_clrscr(void) vmem_ptr = get_vmem(&vstat); rows = vstat.rows; cols = vstat.cols; - for(y = cio_textinfo.wintop-1; y < cio_textinfo.winbottom && y < rows; y++) { - for(x=cio_textinfo.winleft-1; x<cio_textinfo.winright && x < cols; x++) { - vc = set_vmem_cell(vmem_ptr, y*cio_textinfo.screenwidth+x, fill, ciolib_fg, ciolib_bg); + for (y = cio_textinfo.wintop - 1; y < cio_textinfo.winbottom && y < rows; y++) { + for (x = cio_textinfo.winleft - 1; x < cio_textinfo.winright && x < cols; x++) { + vc = set_vmem_cell(vmem_ptr, y * cio_textinfo.screenwidth + x, fill, ciolib_fg, ciolib_bg); bitmap_draw_one_char(vc, x+1, y+1); } } diff --git a/src/syncterm/fonts.c b/src/syncterm/fonts.c index afdef4c9ae923878e30673634dc03a4e9165573a..3547e1bd81c485d48de2550798dec3b85aabcab0 100644 --- a/src/syncterm/fonts.c +++ b/src/syncterm/fonts.c @@ -370,7 +370,7 @@ font_management(void) struct text_info ti; gettextinfo(&ti); - savbuf = alloca((ti.screenheight - 2) * ti.screenwidth * sizeof(*savbuf)); + savbuf = alloca((ti.screenheight - 2U) * ti.screenwidth * sizeof(*savbuf)); if (savbuf == NULL) { uifc.helpbuf = "malloc() has failed. Available Memory is dangerously low."; uifc.msg("malloc() failure."); diff --git a/src/syncterm/ripper.c b/src/syncterm/ripper.c index ef881a7cf8c092e999daa9f140df7de266b71324..7adc46d9740aa8f6af397628e8a94ac3cab43871 100644 --- a/src/syncterm/ripper.c +++ b/src/syncterm/ripper.c @@ -15084,7 +15084,7 @@ draw_glyph(uint8_t ch) fk = htons(*(uint16_t *)(&fd[off + amiga_font->kernOffset + (ch - amiga_font->first) * 2])); voff = (amiga_font->height - amiga_font->baseline - 1) << doubled; for (i = 0; i < amiga_font->height; i++) { - pd = &fd[off + amiga_font->dataOffset + i * amiga_font->modulo]; + pd = &fd[off + amiga_font->dataOffset + (size_t)i * amiga_font->modulo]; pd += (bitoff >> 3); currbit = 7 - (bitoff & 0x07); for (j = 0; j < width; j++) {