aboutsummaryrefslogtreecommitdiffstats
path: root/src/command.c
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2008-10-11 21:46:00 -0700
committerEric Wong <normalperson@yhbt.net>2008-10-12 05:27:32 -0700
commit3e652ee92d4bbe2a9e68cc80b6d58a7f0e6a6093 (patch)
tree44c02b1193ee8448128c38fdac49cef1964a04a5 /src/command.c
parent0fd45f50ec56bcfacae3f6f141ea804b9ac3493f (diff)
downloadmpd-3e652ee92d4bbe2a9e68cc80b6d58a7f0e6a6093.tar.gz
mpd-3e652ee92d4bbe2a9e68cc80b6d58a7f0e6a6093.tar.xz
mpd-3e652ee92d4bbe2a9e68cc80b6d58a7f0e6a6093.zip
update: validate in command.c and fix small memory leak
If update_task was called with "" as its path argument, that string would never get freed because it false positived. Instead, never pass "" to update_task and trip an assertion if we do.
Diffstat (limited to '')
-rw-r--r--src/command.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/command.c b/src/command.c
index f583f82a1..04e85c6fe 100644
--- a/src/command.c
+++ b/src/command.c
@@ -802,9 +802,15 @@ static int handleUpdate(int fd, mpd_unused int *permission,
char *path = NULL;
assert(argc <= 2);
- if (argc == 2 && !(path = sanitizePathDup(argv[1]))) {
- commandError(fd, ACK_ERROR_ARG, "invalid path");
- return -1;
+ if (argc == 2) {
+ if (!(path = sanitizePathDup(argv[1]))) {
+ commandError(fd, ACK_ERROR_ARG, "invalid path");
+ return -1;
+ }
+ if (path_is_music_root(path)) {
+ free(path);
+ path = NULL;
+ }
}
return print_update_result(fd, directory_update_init(path));
}