From 8855efebc0488555b5a985589ee1f070c352c687 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 7 Aug 2012 23:37:38 +0200 Subject: locate: don't allow empty list --- src/DatabaseCommands.cxx | 30 ++++++------------------------ src/command.c | 10 ++-------- src/locate.c | 2 +- 3 files changed, 9 insertions(+), 33 deletions(-) (limited to 'src') diff --git a/src/DatabaseCommands.cxx b/src/DatabaseCommands.cxx index dc2b9fc15..6c6d8965a 100644 --- a/src/DatabaseCommands.cxx +++ b/src/DatabaseCommands.cxx @@ -62,10 +62,7 @@ handle_find(struct client *client, int argc, char *argv[]) struct locate_item_list *list = locate_item_list_parse(argv + 1, argc - 1, false); - if (list == NULL || list->length == 0) { - if (list != NULL) - locate_item_list_free(list); - + if (list == NULL) { command_error(client, ACK_ERROR_ARG, "incorrect arguments"); return COMMAND_RETURN_ERROR; } @@ -85,10 +82,7 @@ handle_findadd(struct client *client, int argc, char *argv[]) { struct locate_item_list *list = locate_item_list_parse(argv + 1, argc - 1, false); - if (list == NULL || list->length == 0) { - if (list != NULL) - locate_item_list_free(list); - + if (list == NULL) { command_error(client, ACK_ERROR_ARG, "incorrect arguments"); return COMMAND_RETURN_ERROR; } @@ -110,10 +104,7 @@ handle_search(struct client *client, int argc, char *argv[]) struct locate_item_list *list = locate_item_list_parse(argv + 1, argc - 1, true); - if (list == NULL || list->length == 0) { - if (list != NULL) - locate_item_list_free(list); - + if (list == NULL) { command_error(client, ACK_ERROR_ARG, "incorrect arguments"); return COMMAND_RETURN_ERROR; } @@ -134,10 +125,7 @@ handle_searchadd(struct client *client, int argc, char *argv[]) struct locate_item_list *list = locate_item_list_parse(argv + 1, argc - 1, true); - if (list == NULL || list->length == 0) { - if (list != NULL) - locate_item_list_free(list); - + if (list == NULL) { command_error(client, ACK_ERROR_ARG, "incorrect arguments"); return COMMAND_RETURN_ERROR; } @@ -161,10 +149,7 @@ handle_searchaddpl(struct client *client, int argc, char *argv[]) struct locate_item_list *list = locate_item_list_parse(argv + 2, argc - 2, true); - if (list == NULL || list->length == 0) { - if (list != NULL) - locate_item_list_free(list); - + if (list == NULL) { command_error(client, ACK_ERROR_ARG, "incorrect arguments"); return COMMAND_RETURN_ERROR; } @@ -186,10 +171,7 @@ handle_count(struct client *client, int argc, char *argv[]) struct locate_item_list *list = locate_item_list_parse(argv + 1, argc - 1, false); - if (list == NULL || list->length == 0) { - if (list != NULL) - locate_item_list_free(list); - + if (list == NULL) { command_error(client, ACK_ERROR_ARG, "incorrect arguments"); return COMMAND_RETURN_ERROR; } diff --git a/src/command.c b/src/command.c index b1d222250..4631e7697 100644 --- a/src/command.c +++ b/src/command.c @@ -679,10 +679,7 @@ handle_playlistfind(struct client *client, int argc, char *argv[]) struct locate_item_list *list = locate_item_list_parse(argv + 1, argc - 1, false); - if (list == NULL || list->length == 0) { - if (list != NULL) - locate_item_list_free(list); - + if (list == NULL) { command_error(client, ACK_ERROR_ARG, "incorrect arguments"); return COMMAND_RETURN_ERROR; } @@ -700,10 +697,7 @@ handle_playlistsearch(struct client *client, int argc, char *argv[]) struct locate_item_list *list = locate_item_list_parse(argv + 1, argc - 1, true); - if (list == NULL || list->length == 0) { - if (list != NULL) - locate_item_list_free(list); - + if (list == NULL) { command_error(client, ACK_ERROR_ARG, "incorrect arguments"); return COMMAND_RETURN_ERROR; } diff --git a/src/locate.c b/src/locate.c index ba58c5d77..6a7002f2e 100644 --- a/src/locate.c +++ b/src/locate.c @@ -88,7 +88,7 @@ locate_item_list_new(unsigned length) struct locate_item_list * locate_item_list_parse(char *argv[], unsigned argc, bool fold_case) { - if (argc % 2 != 0) + if (argc == 0 || argc % 2 != 0) return NULL; struct locate_item_list *list = locate_item_list_new(argc / 2); -- cgit v1.2.3