summaryrefslogtreecommitdiffstats
path: root/ctxopt.c
diff options
context:
space:
mode:
authorpgen <p.gen.progs@gmail.com>2022-06-17 18:09:06 +0200
committerpgen <p.gen.progs@gmail.com>2022-06-17 18:09:06 +0200
commitbff2bc4cfeea83066d4b84189091d8218f1c0567 (patch)
treefa887d2800503752b1f7397bdbeafc66e0e36495 /ctxopt.c
parent4611c03973a17015cbff3d39d446f8ca691ca6d1 (diff)
Sync with github's ctxopt commit 1015378
Diffstat (limited to 'ctxopt.c')
-rw-r--r--ctxopt.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/ctxopt.c b/ctxopt.c
index 66be39a..0bedeb9 100644
--- a/ctxopt.c
+++ b/ctxopt.c
@@ -621,15 +621,18 @@ ll_new(void)
static void
ll_free(ll_t * const list, void (*clean)(void *))
{
+ void * data;
+
if (list)
- while (list->head)
+ while (list->len > 0)
{
+ data = list->head->data;
+ ll_delete(list, list->head);
+
/* Apply a custom cleaner if not NULL. */
/* """"""""""""""""""""""""""""""""""" */
if (clean)
- clean(list->head->data);
-
- ll_delete(list, list->head);
+ clean(data);
}
}
@@ -4147,7 +4150,7 @@ ctxopt_new_ctx(char * name, char * opts_specs)
/* ALPHA+(ALPHANUM|_)* */
/* """"""""""""""""""""""""""" */
p = name;
- if (!isalpha(*p))
+ if (*p == '\0' || !isalpha(*p))
fatal_internal("A context name must start with a letter: %s.", name);
p++;