plug a potential memory leak in M_SaveConfig

This commit is contained in:
Alug 2026-02-02 16:11:41 +01:00 committed by NepDisk
parent 8e025b97c2
commit 0648916c4a
2 changed files with 13 additions and 6 deletions

View file

@ -1332,6 +1332,7 @@ static char *CHAT_WordWrap(INT32 x, INT32 w, INT32 option, const char *string)
x = 0;
}
}
return newstring;
}
@ -1370,7 +1371,7 @@ static void HU_drawMiniChat(void)
emote_t *emote = NULL;
int emotelen = 0;
while(msg[j]) // iterate through msg
while (msg[j]) // iterate through msg
{
if (msg[j] < HU_FONTSTART) // don't draw
{
@ -1402,14 +1403,17 @@ static void HU_drawMiniChat(void)
{
j++;
}
prev_linereturn = false;
dx += charwidth;
if (dx >= boxw)
{
dx = 0;
linescount += 1;
}
}
dy = 0;
dx = 0;
msglines += linescount+1;
@ -1449,7 +1453,7 @@ static void HU_drawMiniChat(void)
emote_t *emote = NULL;
int emotelen = 0;
while(msg[j]) // iterate through msg
while (msg[j]) // iterate through msg
{
if (msg[j] < HU_FONTSTART) // don't draw
{
@ -1494,12 +1498,14 @@ static void HU_drawMiniChat(void)
dx += charwidth;
prev_linereturn = false;
if (dx >= boxw)
{
dx = 0;
dy += charheight;
}
}
dy += charheight;
dx = 0;
@ -1558,7 +1564,7 @@ static void HU_drawChatLog(INT32 offset)
V_DrawFillConsoleMap(chatx, chat_topy, boxw, boxh*charheight +2, 159|V_SNAPTOBOTTOM|V_SNAPTOLEFT); // log box
for (i=0; i<chat_nummsg_log; i++) // iterate through our chatlog
for (i = 0; i < chat_nummsg_log; i++) // iterate through our chatlog
{
INT32 clrflag = 0;
INT32 j = 0;
@ -1567,7 +1573,7 @@ static void HU_drawChatLog(INT32 offset)
emote_t *emote = NULL;
int emotelen = 0;
while(msg[j]) // iterate through msg
while (msg[j]) // iterate through msg
{
if (msg[j] < HU_FONTSTART) // don't draw
{
@ -1612,6 +1618,7 @@ static void HU_drawChatLog(INT32 offset)
dy += charheight;
}
}
dy += charheight;
dx = 0;

View file

@ -602,7 +602,7 @@ void M_FirstLoadConfig(void)
void M_SaveConfig(const char *filename)
{
FILE *f;
char *filepath;
CLEANUP(Z_Pfree) char *filepath = NULL;
char backupfile[MAX_WADPATH+4];
// make sure not to write back the config until it's been correctly loaded
@ -637,7 +637,7 @@ void M_SaveConfig(const char *filename)
// append srb2home to beginning of filename
// but check if srb2home isn't already there, first
if (!strstr(filename, srb2home))
filepath = va(pandf,srb2home, filename);
filepath = Z_StrDup(va(pandf, srb2home, filename));
else
filepath = Z_StrDup(filename);