Avoid integer overflow in Mosaic maximum-size check

This commit is contained in:
Ben Harris
2023-01-10 21:12:46 +00:00
parent 9e2e0692ed
commit 48e3452264

View File

@ -241,7 +241,7 @@ static const char *validate_params(const game_params *params, bool full)
if (params->height < 3 || params->width < 3) {
return "Minimal size is 3x3";
}
if (params->height * params->width > MAX_TILES) {
if (params->height > MAX_TILES / params->width) {
return MAX_TILES_ERROR;
}
return NULL;