Skip to content

Commit 5b130aa

Browse files
Fix potentially invalid pointer being passed to free
1 parent 52bbe28 commit 5b130aa

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

Quake/host_cmd.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1087,24 +1087,25 @@ static void Modlist_Add (const char *name)
10871087
for (i = com_numbasedirs - 1; i >= 0; i--)
10881088
{
10891089
char path[MAX_OSPATH];
1090-
char *description, *end;
1090+
char *buf, *description, *end;
10911091

10921092
if (q_snprintf (path, sizeof (path), "%s/%s/descript.ion", com_basedirs[i], name) >= sizeof (path))
10931093
continue;
10941094

1095-
description = (char *) COM_LoadMallocFile_TextMode_OSPath (path, NULL);
1096-
if (!description)
1095+
buf = (char *) COM_LoadMallocFile_TextMode_OSPath (path, NULL);
1096+
if (!buf)
10971097
continue;
10981098

1099+
description = buf;
10991100
while (q_isspace (*description))
11001101
++description;
11011102
end = strchr (description, '\n');
11021103
if (end)
11031104
*end = '\0';
11041105
if (*description)
11051106
info->full_name = strdup (description);
1106-
free (description);
1107-
1107+
free (buf);
1108+
11081109
if (info->full_name)
11091110
break;
11101111
}

0 commit comments

Comments
 (0)