I_Error if ENCORE/TWEAKMAP has an incorrect size

Prevent memory errors if the lump is too large.
This commit is contained in:
James R 2023-03-26 06:28:39 -07:00
parent 954127d533
commit 6bc785c099
2 changed files with 9 additions and 0 deletions

View file

@ -7877,6 +7877,13 @@ boolean P_LoadLevel(boolean fromnetsave, boolean reloadinggamestate)
if (encoreLump)
{
if (encoreLump->size != 256)
{
I_Error("%s: %s lump is not 256 bytes (actual size %s bytes)\n"
"Make sure the lump is in DOOM Flat or SRB2 Encore format and 16x16",
maplumpname, encoreLump->name, sizeu1(encoreLump->size));
}
R_ReInitColormaps(mapheaderinfo[gamemap-1]->palette, encoreLump->data, encoreLump->size);
}
else

View file

@ -314,6 +314,8 @@ void R_ReInitColormaps(UINT16 num, void *newencoremap, size_t encoremapsize)
lighttable_t *colormap_p, *colormap_p2;
size_t p, i;
I_Assert(encoremapsize == 256);
encoremap = Z_MallocAlign(256 + 10, PU_LEVEL, NULL, 8);
M_Memcpy(encoremap, newencoremap, encoremapsize);
colormap_p = colormap_p2 = colormaps;