From 8636b3185268e8de90c566d472c52b814111b8c3 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 11 Oct 2008 21:09:08 -0700 Subject: Avoid calling isRootDirectory when we have a directory object There is only one music_root and we can just compare addresses. --- src/command.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/command.c') diff --git a/src/command.c b/src/command.c index 518bf5f0d..f583f82a1 100644 --- a/src/command.c +++ b/src/command.c @@ -571,7 +571,7 @@ static int handleLsInfo(int fd, mpd_unused int *permission, directory_print(fd, dir); - if (isRootDirectory(path)) + if (dir == &music_root) return lsPlaylists(fd, path); return 0; -- cgit v1.2.3 From 3e652ee92d4bbe2a9e68cc80b6d58a7f0e6a6093 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 11 Oct 2008 21:46:00 -0700 Subject: 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. --- src/command.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/command.c') 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)); } -- cgit v1.2.3