1
0
mirror of https://github.com/irssi/irssi.git synced 2024-12-04 14:46:39 -05:00

cmd_get_params() crashed in some conditions

git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1489 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
Timo Sirainen 2001-05-11 18:44:51 +00:00 committed by cras
parent 0ec7e8ed58
commit f1774f1a3b

View File

@ -649,6 +649,7 @@ static char *get_optional_channel(CHANNEL_REC *active_channel, char **data)
int cmd_get_params(const char *data, gpointer *free_me, int count, ...) int cmd_get_params(const char *data, gpointer *free_me, int count, ...)
{ {
CHANNEL_REC *chanrec;
CMD_TEMP_REC *rec; CMD_TEMP_REC *rec;
GHashTable **opthash; GHashTable **opthash;
char **str, *arg, *datad; char **str, *arg, *datad;
@ -665,6 +666,10 @@ int cmd_get_params(const char *data, gpointer *free_me, int count, ...)
datad = rec->data; datad = rec->data;
error = FALSE; error = FALSE;
chanrec = (count & PARAM_FLAG_OPTCHAN) == 0 ? NULL:
(CHANNEL_REC *) va_arg(args, CHANNEL_REC *);
if (count & PARAM_FLAG_OPTIONS) { if (count & PARAM_FLAG_OPTIONS) {
arg = (char *) va_arg(args, char *); arg = (char *) va_arg(args, char *);
opthash = (GHashTable **) va_arg(args, GHashTable **); opthash = (GHashTable **) va_arg(args, GHashTable **);
@ -683,14 +688,11 @@ int cmd_get_params(const char *data, gpointer *free_me, int count, ...)
cnt = PARAM_WITHOUT_FLAGS(count); cnt = PARAM_WITHOUT_FLAGS(count);
if (count & PARAM_FLAG_OPTCHAN) { if (count & PARAM_FLAG_OPTCHAN) {
/* optional channel as first parameter */ /* optional channel as first parameter */
CHANNEL_REC *chanrec; arg = get_optional_channel(chanrec, &datad);
chanrec = (CHANNEL_REC *) va_arg(args, CHANNEL_REC *);
arg = get_optional_channel(chanrec, &datad);
str = (char **) va_arg(args, char **); str = (char **) va_arg(args, char **);
if (str != NULL) *str = arg; if (str != NULL) *str = arg;
cnt--; cnt--;
} }
while (cnt-- > 0) { while (cnt-- > 0) {