fix some potential leaks

This commit is contained in:
Alug committed 2025-09-27 18:16:23 +02:00
1 parent 2434acf825
commit 65bd06aae5
4 files changed
+11 -13

No files matched your search

+2
View File
@@ -3584,6 +3584,8 @@ void G_SaveGameData(boolean force)
if (!FIL_CopyFile(gamedatafilename, backupfile))
{
CONS_Alert(CONS_WARNING,"Failed to create a backup of save data. Will not attempt to write to save data\n");
free(save.buffer);
save.p = save.buffer = NULL;
return;
}
}
-4
View File
@@ -455,7 +455,6 @@ void HWR_RenderBatches(void)
{
GL_SetShader(nextShader);
currentShader = nextShader;
changeShader = false;
ps_hw_numshaders.value.i++;
}
@@ -465,7 +464,6 @@ void HWR_RenderBatches(void)
// texture should be already ready for use from calls to GL_SetTexture during batch collection
GL_SetTexture(nextTexture);
currentTexture = nextTexture;
changeTexture = false;
ps_hw_numtextures.value.i++;
}
@@ -473,7 +471,6 @@ void HWR_RenderBatches(void)
if (changePolyFlags)
{
currentPolyFlags = nextPolyFlags;
changePolyFlags = false;
ps_hw_numpolyflags.value.i++;
}
@@ -481,7 +478,6 @@ void HWR_RenderBatches(void)
if (changeSurfaceInfo)
{
currentSurfaceInfo = nextSurfaceInfo;
changeSurfaceInfo = false;
ps_hw_numcolors.value.i++;
}
+7 -5
View File
@@ -974,7 +974,7 @@ void HWR_CreatePlanePolygons(INT32 bspnum)
CONS_Debug(DBG_RENDER, "Looking for boundaries of map...\n");
#endif
M_ClearBox(rootbbox);
for (i = 0;i < numvertexes; i++)
for (i = 0; i < numvertexes; i++)
M_AddToBox(rootbbox, vertexes[i].x, vertexes[i].y);
#ifdef DEBUG_HWBSP
@@ -985,8 +985,8 @@ void HWR_CreatePlanePolygons(INT32 bspnum)
// allocate extra data for each subsector present in map
totsubsectors = numsubsectors + NEWSUBSECTORS;
extrasubsectors = calloc(totsubsectors, sizeof (*extrasubsectors));
if (UNLIKELY(extrasubsectors == NULL))
extrasubsectors = calloc(totsubsectors, sizeof(*extrasubsectors));
if (UNLIKELY(!extrasubsectors))
I_Error("couldn't malloc extrasubsectors totsubsectors %s\n", sizeu1(totsubsectors));
// number of the first new subsector that might be added
@@ -1009,11 +1009,13 @@ void HWR_CreatePlanePolygons(INT32 bspnum)
rootpv->y = FIXED_TO_FLOAT(rootbbox[BOXBOTTOM]); //ll
rootpv++;
WalkBSPNode(bspnum, rootp, NULL,rootbbox);
WalkBSPNode(bspnum, rootp, NULL, rootbbox);
i = SolveTProblem();
#ifdef DEBUG_HWBSP
i = SolveTProblem();
CONS_Debug(DBG_RENDER, "%d point divides a polygon line\n",i);
#else
SolveTProblem();
#endif
AdjustSegs();
+2 -4
View File
@@ -1234,8 +1234,8 @@ static void HU_SendChatMessage(void)
if (len > 4 && strnicmp(msg, "/pm", 3) == 0) // used /pm
{
INT32 spc = 1; // used if nodenum[1] is a space.
char *nodenum = (char*) malloc(3);
const char *newmsg;
CLEANUP(pfree) char *nodenum = (char*) malloc(3);
// what we're gonna do now is check if the node exists
// with that logic, characters 4 and 5 are our numbers:
@@ -1260,7 +1260,6 @@ static void HU_SendChatMessage(void)
else
{
HU_AddChatText("\x82NOTICE: \x80Invalid command format. Correct format is \'/pm<node> \'.", false);
free(nodenum);
return;
}
}
@@ -1270,13 +1269,11 @@ static void HU_SendChatMessage(void)
if (msg[5] != ' ')
{
HU_AddChatText("\x82NOTICE: \x80Invalid command format. Correct format is \'/pm<node> \'.", false);
free(nodenum);
return;
}
}
target = atoi((const char*) nodenum); // turn that into a number
free(nodenum);
//CONS_Printf("%d\n", target);
// check for target player, if it doesn't exist then we can't send the message!
@@ -1292,6 +1289,7 @@ static void HU_SendChatMessage(void)
newmsg = msg+5+spc;
strlcpy(msg, newmsg, HU_MAXMSGLEN + 1);
}
if (ci > 3) // don't send target+flags+empty message.
{
if (teamtalk)