Skip to content

Commit

Permalink
Copy tab completion type strings to hunk
Browse files Browse the repository at this point in the history
instead of assuming they're all literals
  • Loading branch information
andrei-drexler committed Aug 4, 2024
1 parent efbddcf commit 3b57ae2
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions Quake/console.c
Original file line number Diff line number Diff line change
Expand Up @@ -1598,7 +1598,7 @@ void Con_AddToTabList (const char *name, const char *partial, const char *type)
tab_t *t,*insert;
char *i_bash, *i_bash2;
const char *i_name, *i_name2;
int len, mark;
int namelen, typelen, mark;

if (!Con_Match (name, partial))
return;
Expand Down Expand Up @@ -1638,11 +1638,16 @@ void Con_AddToTabList (const char *name, const char *partial, const char *type)
}

mark = Hunk_LowMark ();
len = strlen (name);
t = (tab_t *) Hunk_AllocName (sizeof (tab_t) + len + 1, "tablist");
memcpy (t + 1, name, len + 1);
namelen = (int) strlen (name) + 1;
typelen = type ? (int) strlen (type) + 1 : 0;
t = (tab_t *) Hunk_AllocName (sizeof (tab_t) + namelen + typelen, "tablist");
t->name = (const char *) (t + 1);
t->type = type;
memcpy ((char *) t->name, name, namelen);
if (type)
{
t->type = t->name + namelen;
memcpy ((char *) t->type, type, typelen);
}
t->count = 1;

if (!tablist) //create list
Expand Down

0 comments on commit 3b57ae2

Please sign in to comment.