fix crash with some WDLs

This commit is contained in:
T1ti
2023-01-29 05:03:37 +01:00
parent dad27c6258
commit 20ab963718

View File

@@ -189,13 +189,15 @@ map_horizon::map_horizon(const std::string& basename, const MapIndex * const ind
wdl_file.read(_tiles[y][x]->height_17, 17 * 17 * sizeof(int16_t));
wdl_file.read(_tiles[y][x]->height_16, 16 * 16 * sizeof(int16_t));
wdl_file.read(&fourcc, 4);
if (fourcc == 'MAHO')
if (wdl_file.getPos() < wdl_file.getSize())
{
wdl_file.read(&size, 4);
assert(size == 0x20);
wdl_file.read(_tiles[y][x]->holes, 16 * sizeof(int16_t));
wdl_file.read(&fourcc, 4);
if (fourcc == 'MAHO')
{
wdl_file.read(&size, 4);
assert(size == 0x20);
wdl_file.read(_tiles[y][x]->holes, 16 * sizeof(int16_t));
}
}
}