Codechange: address CodeQL issue "Multiplication result converted to larger type" (#10306)
Most are very unlikely to ever be triggered in our codebase; two stand out: linkgraph and money cheat. Those, potentially, could wrap earlier than expected.
This commit is contained in:
@@ -31,9 +31,10 @@ void Blitter_40bppAnim::SetPixel(void *video, int x, int y, uint8 colour)
|
||||
if (_screen_disable_anim) {
|
||||
Blitter_32bppOptimized::SetPixel(video, x, y, colour);
|
||||
} else {
|
||||
*((Colour *)video + x + y * _screen.pitch) = _black_colour;
|
||||
size_t y_offset = static_cast<size_t>(y) * _screen.pitch;
|
||||
*((Colour *)video + x + y_offset) = _black_colour;
|
||||
|
||||
VideoDriver::GetInstance()->GetAnimBuffer()[((uint32 *)video - (uint32 *)_screen.dst_ptr) + x + y * _screen.pitch] = colour;
|
||||
VideoDriver::GetInstance()->GetAnimBuffer()[((uint32 *)video - (uint32 *)_screen.dst_ptr) + x + y_offset] = colour;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -500,9 +501,9 @@ void Blitter_40bppAnim::ScrollBuffer(void *video, int &left, int &top, int &widt
|
||||
Blitter_32bppBase::ScrollBuffer(video, left, top, width, height, scroll_x, scroll_y);
|
||||
}
|
||||
|
||||
int Blitter_40bppAnim::BufferSize(int width, int height)
|
||||
size_t Blitter_40bppAnim::BufferSize(uint width, uint height)
|
||||
{
|
||||
return width * height * (sizeof(uint32) + sizeof(uint8));
|
||||
return (sizeof(uint32) + sizeof(uint8)) * width * height;
|
||||
}
|
||||
|
||||
Blitter::PaletteAnimation Blitter_40bppAnim::UsePaletteAnimation()
|
||||
|
Reference in New Issue
Block a user