mirror of
https://github.com/gbdev/rgbds.git
synced 2026-08-20 22:04:32 +00:00
Prevent 32-bit multiplication overflow
Basically impossible to achieve, but just in case
This commit is contained in:
+2
-2
@@ -1146,10 +1146,10 @@ continue_visiting_tiles:;
|
||||
uint32_t const nbTilesH = image.png.height / 8, nbTilesW = image.png.width / 8;
|
||||
|
||||
// Check the tile count
|
||||
if (uint32_t nbTiles = nbTilesW * nbTilesH;
|
||||
if (uint64_t nbTiles = nbTilesW * nbTilesH;
|
||||
nbTiles > options.maxNbTiles[0] + options.maxNbTiles[1]) {
|
||||
fatal(
|
||||
"Image contains %" PRIu32 " tiles, exceeding the limit of %" PRIu16 " + %" PRIu16,
|
||||
"Image contains %" PRIu64 " tiles, exceeding the limit of %" PRIu16 " + %" PRIu16,
|
||||
nbTiles,
|
||||
options.maxNbTiles[0],
|
||||
options.maxNbTiles[1]
|
||||
|
||||
Reference in New Issue
Block a user