diff options
author | Eric Wong <normalperson@yhbt.net> | 2008-09-29 02:06:58 -0700 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2008-09-29 02:06:58 -0700 |
commit | 769939b62f7557f8e7c483223d68a8b39af43e37 (patch) | |
tree | 8fc8ca9751756cff80ff246bd6a8cb6477e56e5c /src | |
parent | d645f0a97a52ac061d1f6a43b798c05df93fc48e (diff) | |
download | mpd-769939b62f7557f8e7c483223d68a8b39af43e37.tar.gz mpd-769939b62f7557f8e7c483223d68a8b39af43e37.tar.xz mpd-769939b62f7557f8e7c483223d68a8b39af43e37.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.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/command.c b/src/command.c index 616132bea..3d4e2ccd5 100644 --- a/src/command.c +++ b/src/command.c @@ -1387,16 +1387,19 @@ static CommandEntry *getCommandEntryAndCheckArgcAndPermission(int fd, 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; } |