From a0c0f38cb947a16a5aebf2b59fb8481866d28f96 Mon Sep 17 00:00:00 2001 From: Luca Boccassi Date: Fri, 30 Jul 2021 15:56:11 +0100 Subject: sqfs_dir_tree_destroy/sqfs_destroy: allow NULL input Many library destructor functions (like free()) allow a NULL pointer as input, and do nothing in that case. This allows easier cleanup patterns: initialize pointers to NULL and then always pass them to the destroyer functions, no need for verbose goto/if-else patterns. Signed-off-by: Luca Boccassi --- lib/sqfs/read_tree.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'lib') diff --git a/lib/sqfs/read_tree.c b/lib/sqfs/read_tree.c index 802446a..feda691 100644 --- a/lib/sqfs/read_tree.c +++ b/lib/sqfs/read_tree.c @@ -179,6 +179,9 @@ void sqfs_dir_tree_destroy(sqfs_tree_node_t *root) { sqfs_tree_node_t *it; + if (!root) + return; + while (root->children != NULL) { it = root->children; root->children = it->next; -- cgit v1.2.3