When doubling the cupgrid.builtgrid, memset the new region to prevent bad info

This commit is contained in:
toaster 2022-12-18 12:25:37 +00:00
parent 6659e78c04
commit 286331b5c9

View file

@ -3523,10 +3523,13 @@ static void M_LevelListFromGametype(INT16 gt)
if (((currentid / (CUPMENU_COLUMNS * CUPMENU_ROWS)) + 1) >= cupgrid.cappages)
{
cupgrid.cappages *= 2;
// Double the size of the buffer, and clear the other stuff.
size_t firstlen = sizeof(cupheader_t*) * cupgrid.cappages * (CUPMENU_COLUMNS * CUPMENU_ROWS);
cupgrid.builtgrid = Z_Realloc(cupgrid.builtgrid,
sizeof(cupheader_t*) * cupgrid.cappages * (CUPMENU_COLUMNS * CUPMENU_ROWS),
firstlen * 2,
PU_STATIC, NULL);
memset(cupgrid.builtgrid + firstlen, 0, firstlen);
cupgrid.cappages *= 2;
}
cupgrid.builtgrid[currentid] = cup;