Fix some G_BuildMapTitle memory leaks (found while writing the next commit)

This commit is contained in:
toaster 2022-12-12 16:44:40 +00:00
parent 5a404799b3
commit 6d3a812ff3
3 changed files with 13 additions and 3 deletions

View file

@ -540,7 +540,9 @@ void DRPC_UpdatePresence(void)
else
{
// Map name on tool tip
snprintf(mapname, 48, "Map: %s", G_BuildMapTitle(gamemap));
char *title = G_BuildMapTitle(gamemap);
snprintf(mapname, 48, "Map: %s", title);
Z_Free(title);
discordPresence.largeImageText = mapname;
}

View file

@ -2358,7 +2358,11 @@ void G_BeginRecording(void)
// Full replay title
demo_p += 64;
snprintf(demo.titlename, 64, "%s - %s", G_BuildMapTitle(gamemap), modeattacking ? "Record Attack" : connectedservername);
{
char *title = G_BuildMapTitle(gamemap);
snprintf(demo.titlename, 64, "%s - %s", title, modeattacking ? "Record Attack" : connectedservername);
Z_Free(title);
}
// demo checksum
demo_p += 16;

View file

@ -3970,7 +3970,11 @@ static void M_DrawReplayHutReplayInfo(menudemo_t *demoref)
x += 85;
if (demoref->map < nummapheaders && mapheaderinfo[demoref->map])
V_DrawString(x, y, V_SNAPTOTOP, G_BuildMapTitle(demoref->map+1));
{
char *title = G_BuildMapTitle(demoref->map+1);
V_DrawString(x, y, V_SNAPTOTOP, title);
Z_Free(title);
}
else
V_DrawString(x, y, V_SNAPTOTOP|V_ALLOWLOWERCASE|V_TRANSLUCENT, "Level is not loaded.");