From 8230c814d6d97bc5b9c4fc9784ec4d86853bab0d Mon Sep 17 00:00:00 2001 From: Carl Smith Date: Wed, 17 Apr 2024 09:06:08 +1200 Subject: [PATCH] Dont print error if apteryx_path_node passed NULL tree It is commonly used to check if a tree has a path and that tree may be completely empty. --- apteryx.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/apteryx.c b/apteryx.c index 423d3c7..0fb9163 100644 --- a/apteryx.c +++ b/apteryx.c @@ -1109,7 +1109,11 @@ apteryx_path_node (GNode *node, const char *path) char *node_name; size_t node_name_len; - ASSERT (node != NULL && path != NULL, return false, "PATH_NODE: Invalid parameters\n"); + ASSERT (path != NULL, return NULL, "PATH_NODE: Invalid parameters\n"); + + /* Common practice to try to find a path in an empty tree */ + if (node == NULL) + return NULL; /* Check path */ path = validate_path (path, NULL);