Fix crash and memory leak in $aliasctl(COMMAND MATCH)

glob_commands() would run off the end of the irc_command array if given a match that matched
the last command.  It also leaked memory because it used m_s3cat() to construct the string,
then passed that to m_strdup().

This fixes these problems by reworking glob_commands(), and at the same time removes the use
of alloca() and wild_match() by using strncmp() instead to match the start of a string.  Move
glob_commands() to alias.c and make it static since it's only used for aliasctl().

Change the 'name' argument of find_command() and find_dll_command() to const char * at the same
time, so that glob_commands()'s prefix argument can be const char * too.
This commit is contained in:
Kevin Easton
2016-10-15 00:41:34 +11:00
parent dec7caafd0
commit 9a2792345f
5 changed files with 32 additions and 28 deletions

View File

@@ -258,8 +258,7 @@ extern void ame (char *, char *, char *, char *);
extern void unload_dll (char *, char *, char *, char *);
#endif
IrcCommand *BX_find_command (char *, int *);
char *glob_commands(char *, int *, int);
IrcCommand *BX_find_command (const char *, int *);
#define AWAY_ONE 0
#define AWAY_ALL 1