diff options
author | Timo Sirainen <cras@irssi.org> | 2001-05-11 18:44:51 +0000 |
---|---|---|
committer | cras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564> | 2001-05-11 18:44:51 +0000 |
commit | f1774f1a3bfdf9b124e708014e8caf3a4f764ce5 (patch) | |
tree | 03947311426fc8499d8540e9885150b09a6a7578 /src/core/commands.c | |
parent | 0ec7e8ed58a0ac9179ce6acf6aebc00b8796c8b5 (diff) | |
download | irssi-f1774f1a3bfdf9b124e708014e8caf3a4f764ce5.zip |
cmd_get_params() crashed in some conditions
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1489 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src/core/commands.c')
-rw-r--r-- | src/core/commands.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/core/commands.c b/src/core/commands.c index f6d71397..b6fb8a74 100644 --- a/src/core/commands.c +++ b/src/core/commands.c @@ -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, ...) { + CHANNEL_REC *chanrec; CMD_TEMP_REC *rec; GHashTable **opthash; char **str, *arg, *datad; @@ -665,6 +666,10 @@ int cmd_get_params(const char *data, gpointer *free_me, int count, ...) datad = rec->data; error = FALSE; + + chanrec = (count & PARAM_FLAG_OPTCHAN) == 0 ? NULL: + (CHANNEL_REC *) va_arg(args, CHANNEL_REC *); + if (count & PARAM_FLAG_OPTIONS) { arg = (char *) va_arg(args, char *); 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); if (count & PARAM_FLAG_OPTCHAN) { /* optional channel as first parameter */ - CHANNEL_REC *chanrec; - - chanrec = (CHANNEL_REC *) va_arg(args, CHANNEL_REC *); - arg = get_optional_channel(chanrec, &datad); + arg = get_optional_channel(chanrec, &datad); str = (char **) va_arg(args, char **); if (str != NULL) *str = arg; - cnt--; + cnt--; } while (cnt-- > 0) { |