close a nasty hole in the gamedir code

This commit is contained in:
Bill Currie 2004-01-07 06:40:10 +00:00
parent 9537640b1c
commit efd6ccff02

View file

@ -352,6 +352,12 @@ qfs_dir_get_key (void *_k, void *unused)
return _k; return _k;
} }
static void
qfs_dir_free (void *_k, void *unused)
{
free (_k);
}
static plitem_t * static plitem_t *
qfs_find_gamedir (const char *name, hashtab_t *dirs) qfs_find_gamedir (const char *name, hashtab_t *dirs)
{ {
@ -401,7 +407,7 @@ qfs_build_gamedir (const char **list)
gamedir_t *gamedir; gamedir_t *gamedir;
plitem_t *gdpl; plitem_t *gdpl;
dstring_t *path; dstring_t *path;
hashtab_t *dirs = Hash_NewTable (31, qfs_dir_get_key, 0, 0); hashtab_t *dirs = Hash_NewTable (31, qfs_dir_get_key, qfs_dir_free, 0);
hashtab_t *vars = qfs_new_vars (); hashtab_t *vars = qfs_new_vars ();
const char *dir = 0; const char *dir = 0;
@ -455,7 +461,7 @@ qfs_build_gamedir (const char **list)
Sys_Printf ("gamedir `%s' not found\n", name); Sys_Printf ("gamedir `%s' not found\n", name);
continue; continue;
} }
Hash_Add (dirs, (void *) name); Hash_Add (dirs, strdup (name));
if (!j) { if (!j) {
gamedir->name = strdup (name); gamedir->name = strdup (name);
gamedir->gamedir = strdup (list[j]); gamedir->gamedir = strdup (list[j]);