aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2008-09-29 13:18:35 +0200
committerMax Kellermann <max@duempel.org>2008-09-29 13:18:35 +0200
commit5f0ed72c489fd1f0b3c38e3608d27966e1f41f88 (patch)
tree4ed5095627a2ff53fd9f1375248673ff1120b2cf
parent11245dc1195c47f425471da927af7da0bca60c3e (diff)
downloadmpd-5f0ed72c489fd1f0b3c38e3608d27966e1f41f88.tar.gz
mpd-5f0ed72c489fd1f0b3c38e3608d27966e1f41f88.tar.xz
mpd-5f0ed72c489fd1f0b3c38e3608d27966e1f41f88.zip
command: don't clobber next list value when preparsing
This only breaks "update" under list command mode and no other commands. This can be done more optimally without the extra heap allocation via xstrdup(); but is uncommon enough to not matter.
Diffstat (limited to '')
-rw-r--r--src/command.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/command.c b/src/command.c
index 6ebcb977c..882d968d3 100644
--- a/src/command.c
+++ b/src/command.c
@@ -1422,16 +1422,19 @@ static CommandEntry *getCommandEntryAndCheckArgcAndPermission(struct client *cli
static CommandEntry *getCommandEntryFromString(char *string, int permission)
{
- CommandEntry *cmd;
+ CommandEntry *cmd = NULL;
char *argv[COMMAND_ARGV_MAX] = { NULL };
- int argc = buffer2array(string, argv, COMMAND_ARGV_MAX);
+ char *duplicated = xstrdup(string);
+ int argc = buffer2array(duplicated, argv, COMMAND_ARGV_MAX);
if (0 == argc)
- return NULL;
+ goto out;
cmd = getCommandEntryAndCheckArgcAndPermission(0, permission,
argc, argv);
+out:
+ free(duplicated);
return cmd;
}