Fix Multiplication result converted to larger type from CodeQL

This commit is contained in:
Jasmine Iwanek
2022-12-23 14:22:17 -05:00
parent ecae3d7b31
commit 231cadb0a7
5 changed files with 12 additions and 12 deletions

View File

@@ -486,9 +486,9 @@ img_seek(int drive, int track)
for (side = 0; side < dev->sides; side++) {
if (dev->disk_at_once) {
cur_pos = (track * dev->sectors * ssize * dev->sides) + (side * dev->sectors * ssize);
memcpy(dev->track_data[side], dev->disk_data + cur_pos, dev->sectors * ssize);
memcpy(dev->track_data[side], dev->disk_data + cur_pos, (size_t) dev->sectors * ssize);
} else {
read_bytes = fread(dev->track_data[side], 1, dev->sectors * ssize, dev->f);
read_bytes = fread(dev->track_data[side], 1, (size_t) dev->sectors * ssize, dev->f);
if (read_bytes < (dev->sectors * ssize))
memset(dev->track_data[side] + read_bytes, 0xf6, (dev->sectors * ssize) - read_bytes);
}

View File

@@ -407,7 +407,7 @@ new_page(escp_t *dev, int8_t save, int8_t resetx)
dev->curr_y = dev->top_margin;
if (dev->page) {
dev->page->dirty = 0;
memset(dev->page->pixels, 0x00, dev->page->pitch * dev->page->h);
memset(dev->page->pixels, 0x00, (size_t) dev->page->pitch * dev->page->h);
}
/* Make the page's file name. */
@@ -451,9 +451,9 @@ fill_palette(uint8_t redmax, uint8_t greenmax, uint8_t bluemax, uint8_t colorID,
colormask = colorID <<= 5;
for (i = 0; i < 32; i++) {
dev->palcol[i + colormask].r = 255 - (uint8_t) floor(red * (float) i);
dev->palcol[i + colormask].g = 255 - (uint8_t) floor(green * (float) i);
dev->palcol[i + colormask].b = 255 - (uint8_t) floor(blue * (float) i);
dev->palcol[i + colormask].r = 255 - (uint8_t) floor((double) red * (float) i);
dev->palcol[i + colormask].g = 255 - (uint8_t) floor((double) green * (float) i);
dev->palcol[i + colormask].b = 255 - (uint8_t) floor((double) blue * (float) i);
}
}
@@ -2043,8 +2043,8 @@ escp_init(void *lpt)
dev->page->w = (int) (dev->dpi * dev->page_width);
dev->page->h = (int) (dev->dpi * dev->page_height);
dev->page->pitch = dev->page->w;
dev->page->pixels = (uint8_t *) malloc(dev->page->pitch * dev->page->h);
memset(dev->page->pixels, 0x00, dev->page->pitch * dev->page->h);
dev->page->pixels = (uint8_t *) malloc((size_t) dev->page->pitch * dev->page->h);
memset(dev->page->pixels, 0x00, (size_t) dev->page->pitch * dev->page->h);
/* Initialize parameters. */
for (i = 0; i < 32; i++) {

View File

@@ -2663,8 +2663,8 @@ pgc_init(pgc_t *dev, int maxw, int maxh, int visw, int vish,
dev->visw = visw;
dev->vish = vish;
dev->vram = (uint8_t *) malloc(maxw * maxh);
memset(dev->vram, 0x00, maxw * maxh);
dev->vram = (uint8_t *) malloc((size_t) maxw * maxh);
memset(dev->vram, 0x00, (size_t) maxw * maxh);
dev->cga_vram = (uint8_t *) malloc(16384);
memset(dev->cga_vram, 0x00, 16384);

View File

@@ -68,7 +68,7 @@ svga_render_blank(svga_t *svga)
}
uint32_t *line_ptr = &buffer32->line[svga->displine + svga->y_add][svga->x_add];
uint32_t line_width = (svga->hdisp + svga->scrollcache) * char_width * sizeof(uint32_t);
uint32_t line_width = (uint32_t) (svga->hdisp + svga->scrollcache) * char_width * sizeof(uint32_t);
memset(line_ptr, 0, line_width);
}

View File

@@ -804,7 +804,7 @@ create_bitmap(int x, int y)
bitmap_t *b = malloc(sizeof(bitmap_t) + (y * sizeof(uint32_t *)));
int c;
b->dat = malloc(x * y * 4);
b->dat = malloc((size_t) x * y * 4);
for (c = 0; c < y; c++)
b->line[c] = &(b->dat[c * x]);
b->w = x;