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:
Patric Stout
2023-01-02 21:30:02 +01:00
committed by GitHub
parent fcbe390353
commit 1fb101eabb
26 changed files with 74 additions and 66 deletions

View File

@@ -188,7 +188,7 @@ static bool ReadHeightmapPNG(const char *filename, uint *x, uint *y, byte **map)
}
if (map != nullptr) {
*map = MallocT<byte>(width * height);
*map = MallocT<byte>(static_cast<size_t>(width) * height);
ReadHeightmapPNGImageData(*map, png_ptr, info_ptr);
}
@@ -303,7 +303,7 @@ static bool ReadHeightmapBMP(const char *filename, uint *x, uint *y, byte **map)
return false;
}
*map = MallocT<byte>(info.width * info.height);
*map = MallocT<byte>(static_cast<size_t>(info.width) * info.height);
ReadHeightmapBMPImageData(*map, &info, &data);
}