Commit 8855efeb authored by Max Kellermann's avatar Max Kellermann

locate: don't allow empty list

parent 7725577a
...@@ -62,10 +62,7 @@ handle_find(struct client *client, int argc, char *argv[]) ...@@ -62,10 +62,7 @@ handle_find(struct client *client, int argc, char *argv[])
struct locate_item_list *list = struct locate_item_list *list =
locate_item_list_parse(argv + 1, argc - 1, false); locate_item_list_parse(argv + 1, argc - 1, false);
if (list == NULL || list->length == 0) { if (list == NULL) {
if (list != NULL)
locate_item_list_free(list);
command_error(client, ACK_ERROR_ARG, "incorrect arguments"); command_error(client, ACK_ERROR_ARG, "incorrect arguments");
return COMMAND_RETURN_ERROR; return COMMAND_RETURN_ERROR;
} }
...@@ -85,10 +82,7 @@ handle_findadd(struct client *client, int argc, char *argv[]) ...@@ -85,10 +82,7 @@ handle_findadd(struct client *client, int argc, char *argv[])
{ {
struct locate_item_list *list = struct locate_item_list *list =
locate_item_list_parse(argv + 1, argc - 1, false); locate_item_list_parse(argv + 1, argc - 1, false);
if (list == NULL || list->length == 0) { if (list == NULL) {
if (list != NULL)
locate_item_list_free(list);
command_error(client, ACK_ERROR_ARG, "incorrect arguments"); command_error(client, ACK_ERROR_ARG, "incorrect arguments");
return COMMAND_RETURN_ERROR; return COMMAND_RETURN_ERROR;
} }
...@@ -110,10 +104,7 @@ handle_search(struct client *client, int argc, char *argv[]) ...@@ -110,10 +104,7 @@ handle_search(struct client *client, int argc, char *argv[])
struct locate_item_list *list = struct locate_item_list *list =
locate_item_list_parse(argv + 1, argc - 1, true); locate_item_list_parse(argv + 1, argc - 1, true);
if (list == NULL || list->length == 0) { if (list == NULL) {
if (list != NULL)
locate_item_list_free(list);
command_error(client, ACK_ERROR_ARG, "incorrect arguments"); command_error(client, ACK_ERROR_ARG, "incorrect arguments");
return COMMAND_RETURN_ERROR; return COMMAND_RETURN_ERROR;
} }
...@@ -134,10 +125,7 @@ handle_searchadd(struct client *client, int argc, char *argv[]) ...@@ -134,10 +125,7 @@ handle_searchadd(struct client *client, int argc, char *argv[])
struct locate_item_list *list = struct locate_item_list *list =
locate_item_list_parse(argv + 1, argc - 1, true); locate_item_list_parse(argv + 1, argc - 1, true);
if (list == NULL || list->length == 0) { if (list == NULL) {
if (list != NULL)
locate_item_list_free(list);
command_error(client, ACK_ERROR_ARG, "incorrect arguments"); command_error(client, ACK_ERROR_ARG, "incorrect arguments");
return COMMAND_RETURN_ERROR; return COMMAND_RETURN_ERROR;
} }
...@@ -161,10 +149,7 @@ handle_searchaddpl(struct client *client, int argc, char *argv[]) ...@@ -161,10 +149,7 @@ handle_searchaddpl(struct client *client, int argc, char *argv[])
struct locate_item_list *list = struct locate_item_list *list =
locate_item_list_parse(argv + 2, argc - 2, true); locate_item_list_parse(argv + 2, argc - 2, true);
if (list == NULL || list->length == 0) { if (list == NULL) {
if (list != NULL)
locate_item_list_free(list);
command_error(client, ACK_ERROR_ARG, "incorrect arguments"); command_error(client, ACK_ERROR_ARG, "incorrect arguments");
return COMMAND_RETURN_ERROR; return COMMAND_RETURN_ERROR;
} }
...@@ -186,10 +171,7 @@ handle_count(struct client *client, int argc, char *argv[]) ...@@ -186,10 +171,7 @@ handle_count(struct client *client, int argc, char *argv[])
struct locate_item_list *list = struct locate_item_list *list =
locate_item_list_parse(argv + 1, argc - 1, false); locate_item_list_parse(argv + 1, argc - 1, false);
if (list == NULL || list->length == 0) { if (list == NULL) {
if (list != NULL)
locate_item_list_free(list);
command_error(client, ACK_ERROR_ARG, "incorrect arguments"); command_error(client, ACK_ERROR_ARG, "incorrect arguments");
return COMMAND_RETURN_ERROR; return COMMAND_RETURN_ERROR;
} }
......
...@@ -679,10 +679,7 @@ handle_playlistfind(struct client *client, int argc, char *argv[]) ...@@ -679,10 +679,7 @@ handle_playlistfind(struct client *client, int argc, char *argv[])
struct locate_item_list *list = struct locate_item_list *list =
locate_item_list_parse(argv + 1, argc - 1, false); locate_item_list_parse(argv + 1, argc - 1, false);
if (list == NULL || list->length == 0) { if (list == NULL) {
if (list != NULL)
locate_item_list_free(list);
command_error(client, ACK_ERROR_ARG, "incorrect arguments"); command_error(client, ACK_ERROR_ARG, "incorrect arguments");
return COMMAND_RETURN_ERROR; return COMMAND_RETURN_ERROR;
} }
...@@ -700,10 +697,7 @@ handle_playlistsearch(struct client *client, int argc, char *argv[]) ...@@ -700,10 +697,7 @@ handle_playlistsearch(struct client *client, int argc, char *argv[])
struct locate_item_list *list = struct locate_item_list *list =
locate_item_list_parse(argv + 1, argc - 1, true); locate_item_list_parse(argv + 1, argc - 1, true);
if (list == NULL || list->length == 0) { if (list == NULL) {
if (list != NULL)
locate_item_list_free(list);
command_error(client, ACK_ERROR_ARG, "incorrect arguments"); command_error(client, ACK_ERROR_ARG, "incorrect arguments");
return COMMAND_RETURN_ERROR; return COMMAND_RETURN_ERROR;
} }
......
...@@ -88,7 +88,7 @@ locate_item_list_new(unsigned length) ...@@ -88,7 +88,7 @@ locate_item_list_new(unsigned length)
struct locate_item_list * struct locate_item_list *
locate_item_list_parse(char *argv[], unsigned argc, bool fold_case) locate_item_list_parse(char *argv[], unsigned argc, bool fold_case)
{ {
if (argc % 2 != 0) if (argc == 0 || argc % 2 != 0)
return NULL; return NULL;
struct locate_item_list *list = locate_item_list_new(argc / 2); struct locate_item_list *list = locate_item_list_new(argc / 2);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment