Skip to content

Commit

Permalink
Fix possible integer overflow when creating an array
Browse files Browse the repository at this point in the history
Signed-off-by: Pavel Solodovnikov <[email protected]>
  • Loading branch information
ManManson committed Nov 28, 2023
1 parent 8ae688b commit 24202f5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,7 @@ static void SetDecals(const char *filename, const char *decal_type)
pFileData = strchr(pFileData, '\n') + 1;
// value initialization sets everything to false.
mapDecals = std::make_unique<bool[]>(MAX_TERRAIN_TILES);

for (i = 0; i < numlines; i++)
{
tiledecal = -1;
Expand Down Expand Up @@ -1011,7 +1011,7 @@ bool mapLoadFromWzMapData(std::shared_ptr<WzMap::MapData> loadedMap)
ASSERT(psMapTiles == nullptr, "Map has not been cleared before calling mapLoad()!");

/* Allocate the memory for the map */
psMapTiles = std::make_unique<MAPTILE[]>(width * height);
psMapTiles = std::make_unique<MAPTILE[]>(static_cast<size_t>(width) * height);
ASSERT(psMapTiles != nullptr, "Out of memory");

mapWidth = width;
Expand Down

0 comments on commit 24202f5

Please sign in to comment.