Commit 22b58503 22b58503041ddd74f2919e28bcbdd08a278dccc5 by Sergey Poznyakoff

Bugfixes.

Setting non-existing variable in bin/mail at the start of the session
caused further calls to set (without arguments) to malfunction.  This
reveiled bugs in list mapping functions.

On the other hand, invoking completion after "set var=" caused bin/mail
to coredump.

* libmailutils/list/gmap.c (mu_list_gmap): Initialize rc.
* libmailutils/list/map.c: Always initialize *res.
* mail/mailvar.c (mailvar_list_copy): The call to mu_list_map
does not necessarily create the list. Create it, if it doesn't.
(mailvar_iterate_next): Redo the loop: check if there are items
to iterate over.
1 parent 645d7338
......@@ -38,6 +38,7 @@ mu_list_gmap (mu_list_t list, mu_list_mapper_t map, size_t nelem, void *data)
return ENOMEM;
i = 0;
rc = 0;
for (current = list->head.next; current != &list->head;
current = current->next)
{
......
......@@ -79,7 +79,6 @@ mu_list_map (mu_list_t list, mu_list_mapper_t map, void *data, size_t nelem,
rc = mu_list_gmap (list, _list_mapper, nelem, &cl);
if (cl.list)
*res = cl.list;
if (rc == MU_ERR_FAILURE)
return cl.status;
......
......@@ -624,11 +624,11 @@ _mailvar_symbol_to_list (int set, mu_list_t list)
mu_list_t
mailvar_list_copy (int set)
{
mu_list_t list;
mu_list_t list = NULL;
if (mailvar_list)
mu_list_map (mailvar_list, mailvar_mapper, NULL, 1, &list);
else
if (!list)
mu_list_create (&list);
_mailvar_symbol_to_list (set, list);
mu_list_sort (list, mailvar_varptr_comp);
......@@ -649,7 +649,7 @@ mailvar_iterate_next (struct mailvar_iterator *itr)
{
struct mailvar_variable *vp;
do
while (!mu_iterator_is_done (itr->varitr))
{
mu_iterator_current (itr->varitr, (void**) &vp);
mu_iterator_next (itr->varitr);
......@@ -658,7 +658,6 @@ mailvar_iterate_next (struct mailvar_iterator *itr)
&& strncmp (vp->name, itr->prefix, itr->prefixlen) == 0)
return vp->name;
}
while (!mu_iterator_is_done (itr->varitr));
return NULL;
}
......