* Correct fr_dlist_talloc_reverse_free() to clear from the very end
* Free map list in reverse due to talloc parenting
* Don't clear head - it is talloc freed by the caller when an error is returned
if (total++ == max) {
cf_log_err(ci, "Map size exceeded");
error:
- fr_dlist_talloc_free(out);
+ /*
+ * Free in reverse as successive entries have their
+ * prececessors as talloc parents
+ */
+ fr_dlist_talloc_reverse_free(out);
return -1;
}
if (func && (func->input_type != XLAT_INPUT_ARGS)) {
fr_strerror_const("Function should be called using the syntax %{func:arg}");
error:
- *head = NULL;
talloc_free(node);
return -1;
}
*/
static inline void fr_dlist_talloc_reverse_free(fr_dlist_head_t *head)
{
- void *e = NULL;
+ void *e = NULL, *p;
e = fr_dlist_tail(head);
do {
- e = fr_dlist_remove(head, e);
+ p = fr_dlist_remove(head, e);
talloc_free(e);
+ e = p;
} while (e);
}