Skip to content

Commit

Permalink
Fix potentially invalid pointer being passed to free
Browse files Browse the repository at this point in the history
  • Loading branch information
andrei-drexler committed Mar 17, 2023
1 parent 52bbe28 commit 5b130aa
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions Quake/host_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1087,24 +1087,25 @@ static void Modlist_Add (const char *name)
for (i = com_numbasedirs - 1; i >= 0; i--)
{
char path[MAX_OSPATH];
char *description, *end;
char *buf, *description, *end;

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

description = (char *) COM_LoadMallocFile_TextMode_OSPath (path, NULL);
if (!description)
buf = (char *) COM_LoadMallocFile_TextMode_OSPath (path, NULL);
if (!buf)
continue;

description = buf;
while (q_isspace (*description))
++description;
end = strchr (description, '\n');
if (end)
*end = '\0';
if (*description)
info->full_name = strdup (description);
free (description);
free (buf);

if (info->full_name)
break;
}
Expand Down

0 comments on commit 5b130aa

Please sign in to comment.