tab completion: lower size of filelist_item_t name buffer from MAX_OSPATH to 32 to avoid filling up the zone memory (this limits the length of maps / games you can tab-complete).

Prior to r1153 it was 32 for maps and MAX_OSPATH for mods.

git-svn-id: svn+ssh://svn.code.sf.net/p/quakespasm/code/trunk@1158 af15c1b1-3010-417e-b628-4374ebc0bcbd
This commit is contained in:
ewasylishen 2015-01-26 23:35:55 +00:00
parent b85b510e7d
commit b4ef94be23
2 changed files with 6 additions and 8 deletions

View file

@ -720,8 +720,6 @@ tablist is a doubly-linked loop, alphabetized by name
// aka Linux Bash shell. -- S.A. // aka Linux Bash shell. -- S.A.
static char bash_partial[80]; static char bash_partial[80];
static qboolean bash_singlematch; static qboolean bash_singlematch;
static qboolean map_singlematch;
static qboolean mod_singlematch;
void AddToTabList (const char *name, const char *type) void AddToTabList (const char *name, const char *type)
{ {
@ -786,7 +784,7 @@ void AddToTabList (const char *name, const char *type)
// This is redefined from host_cmd.c // This is redefined from host_cmd.c
typedef struct filelist_item_s typedef struct filelist_item_s
{ {
char name[MAX_OSPATH]; char name[32];
struct filelist_item_s *next; struct filelist_item_s *next;
} filelist_item_t; } filelist_item_t;
@ -816,12 +814,12 @@ FindCompletion -- stevenaaus
*/ */
const char *FindCompletion (const char *partial, filelist_item_t *filelist, int *nummatches_out) const char *FindCompletion (const char *partial, filelist_item_t *filelist, int *nummatches_out)
{ {
static char matched[MAX_OSPATH]; static char matched[32];
char *i_matched, *i_name; char *i_matched, *i_name;
filelist_item_t *file; filelist_item_t *file;
int init, match, plen; int init, match, plen;
memset(matched, 0, MAX_OSPATH); memset(matched, 0, sizeof(matched));
plen = strlen(partial); plen = strlen(partial);
match = 0; match = 0;
@ -832,8 +830,8 @@ const char *FindCompletion (const char *partial, filelist_item_t *filelist, int
if (init == 0) if (init == 0)
{ {
init = 1; init = 1;
strncpy (matched, file->name, MAX_OSPATH-1); strncpy (matched, file->name, sizeof(matched)-1);
matched[MAX_OSPATH-1] = '\0'; matched[sizeof(matched)-1] = '\0';
} }
else else
{ // find max common { // find max common

View file

@ -59,7 +59,7 @@ void Host_Quit_f (void)
// to simplify completion code // to simplify completion code
typedef struct filelist_item_s typedef struct filelist_item_s
{ {
char name[MAX_OSPATH]; char name[32];
struct filelist_item_s *next; struct filelist_item_s *next;
} filelist_item_t; } filelist_item_t;