Fix buffer overflow when linedef type 415 executes

This commit is contained in:
Gustaf Alhäll 2023-06-02 22:19:30 +02:00 committed by GenericHeroGuy
parent dce0dca850
commit 3d43d01ca6

View file

@ -3007,7 +3007,15 @@ boolean P_ProcessSpecial(activator_t *activator, INT16 special, INT32 *args, cha
if (lumpnum == LUMPERROR || W_LumpLength(lumpnum) == 0)
CONS_Debug(DBG_SETUP, "Line type 415 Executor: script lump %s not found/not valid.\n", stringargs[0]);
else
COM_BufInsertText(W_CacheLumpNum(lumpnum, PU_CACHE));
{
void *lump = W_CacheLumpNum(lumpnum, PU_CACHE);
size_t len = W_LumpLength(lumpnum);
char *text = Z_Malloc(len + 1, PU_CACHE, NULL);
memcpy(text, lump, len);
text[len] = '\0';
COM_BufInsertText(text);
Z_Free(text);
}
}
break;