Mercurial > dovecot > core-2.2
changeset 19498:d397b0ad0ac4
lib-storage: Fixed mail_search_args_simplify() with empty args.
This fixes assert-crash in doveadm mailbox list.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Wed, 09 Dec 2015 13:51:35 +0200 |
parents | 1d2999cfe0a4 |
children | 097a0175a591 |
files | src/lib-storage/mail-search-args-simplify.c src/lib-storage/test-mail-search-args-simplify.c |
diffstat | 2 files changed, 18 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-storage/mail-search-args-simplify.c Wed Dec 09 13:02:46 2015 +0200 +++ b/src/lib-storage/mail-search-args-simplify.c Wed Dec 09 13:51:35 2015 +0200 @@ -344,6 +344,9 @@ unsigned int count, lowest_count = UINT_MAX; bool ret = FALSE; + if (*argsp == NULL) + return FALSE; + child_subargs_type = and_arg ? SEARCH_OR : SEARCH_SUB; /* find the arg which has the lowest number of child args */ @@ -399,7 +402,7 @@ struct mail_search_arg *new_arg, *child_arg, *common_args = NULL; enum mail_search_arg_type child_subargs_type; - if ((*argsp)->next == NULL) { + if (*argsp == NULL || (*argsp)->next == NULL) { /* single arg, nothing to extract */ return FALSE; }
--- a/src/lib-storage/test-mail-search-args-simplify.c Wed Dec 09 13:02:46 2015 +0200 +++ b/src/lib-storage/test-mail-search-args-simplify.c Wed Dec 09 13:51:35 2015 +0200 @@ -202,10 +202,24 @@ test_end(); } +static void test_mail_search_args_simplify_empty_lists(void) +{ + struct mail_search_args *args; + + test_begin("mail search args simplify empty args"); + + args = mail_search_build_init(); + mail_search_args_simplify(args); + mail_search_args_unref(&args); + + test_end(); +} + int main(void) { static void (*test_functions[])(void) = { test_mail_search_args_simplify, + test_mail_search_args_simplify_empty_lists, NULL };