From d0d9ac2d770ad66de042e3efad7666031c1ae960 Mon Sep 17 00:00:00 2001 From: Levi Neely <141506390+lneely@users.noreply.github.com> Date: Tue, 3 Mar 2026 15:29:44 +0100 Subject: [PATCH] Fix ptree_for_each_element loop termination condition (#319) Daemon tested, starts successfully --- pclsync/ptree.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pclsync/ptree.h b/pclsync/ptree.h index 753c9bf..ebc12f9 100644 --- a/pclsync/ptree.h +++ b/pclsync/ptree.h @@ -49,8 +49,9 @@ typedef struct _psync_tree { #define ptree_for_each(a, l) \ for (a = ptree_get_first(l); a != NULL; a = ptree_get_next(a)) #define ptree_for_each_element(a, l, t, n) \ - for (a = ptree_element(ptree_get_first(l), t, n); &a->n != NULL; \ - a = ptree_element(ptree_get_next(&a->n), t, n)) + for (a = (ptree_get_first(l) ? ptree_element(ptree_get_first(l), t, n) : NULL); \ + a != NULL; \ + a = (ptree_get_next(&a->n) ? ptree_element(ptree_get_next(&a->n), t, n) : NULL)) #define ptree_for_each_element_call(l, t, n, c) \ do { \