fix some null pointer dereferences

Based on b0bf588c27
and 67e74b5874
This commit is contained in:
NepDisk 2025-12-29 13:11:58 -05:00
parent ae9fd3b63d
commit 701b7436de
2 changed files with 19 additions and 4 deletions

View file

@ -1728,14 +1728,15 @@ void M_MinimapGenerate(void)
minigen = AM_MinimapGenerate(mul);
if (minigen == NULL || minigen->buf == NULL)
goto failure;
{
CONS_Alert(CONS_ERROR, M_GetText("Couldn't create %s\n"), filepath);
return;
}
M_CreateScreenShotPalette();
ret = M_SavePNG(filepath, minigen->buf, minigen->w, minigen->h, screenshot_palette);
failure:
if (minigen->buf != NULL)
free(minigen->buf);
free(minigen->buf);
if (ret)
{

View file

@ -2300,11 +2300,16 @@ void *W_CachePatchNameRotated(const char *name, INT32 rotationangle, INT32 tag)
rspr = (rotsprite_t *)W_GetCachedRotPatchPwad(WADFILENUM(num),LUMPNUM(num));
if (rspr == NULL)
return W_CachePatchNum(W_GetNumForName("MISSING"), tag);
if (rspr->patches[idx] == NULL)
{
INT32 xpivot = 0, ypivot = 0;
ptr = (patch_t *)W_CachePatchNum(num, PU_PATCH);
if (ptr == NULL)
return W_CachePatchNum(W_GetNumForName("MISSING"), tag);
// >y pivot centered
// >x pivot not centered
@ -2699,6 +2704,9 @@ virtres_t* vres_GetMap(lumpnum_t lumpnum)
// Remember that we're assuming that the WAD will have a specific set of lumps in a specific order.
UINT8 *wadData = (UINT8 *)W_CacheLumpNum(lumpnum, PU_LEVEL);
if (wadData == NULL)
I_Error("vres_GetMap: Invalid WadData!\n");
filelump_t *fileinfo = (filelump_t *)(wadData + ((wadinfo_t *)wadData)->infotableofs);
i = ((wadinfo_t *)wadData)->numlumps;
@ -2716,6 +2724,9 @@ virtres_t* vres_GetMap(lumpnum_t lumpnum)
vlumps = (virtlump_t *)Z_Malloc(sizeof(virtlump_t)*numlumps, PU_LEVEL, NULL);
if (vlumps == NULL)
I_Error("vres_GetMap: Out of memory!\n");
// Build the lumps, skipping over empty entries.
for (i = 0, realentry = 0; i < numlumps; realentry++)
{
@ -2758,6 +2769,9 @@ virtres_t* vres_GetMap(lumpnum_t lumpnum)
numlumps++;
vlumps = (virtlump_t *)Z_Malloc(sizeof(virtlump_t)*numlumps, PU_LEVEL, NULL);
if (vlumps == NULL)
I_Error("vres_GetMap: Out of memory!\n");
for (i = 0; i < numlumps; i++, lumpnum++)
{
vlumps[i].size = W_LumpLength(lumpnum);