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

@@ -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;