summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorLuca Boccassi <luca.boccassi@microsoft.com>2021-07-30 15:56:11 +0100
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2022-03-30 22:31:30 +0200
commita0c0f38cb947a16a5aebf2b59fb8481866d28f96 (patch)
treecdb566c89666f62b78bd3e432140aa86b23bf67a /lib
parent7667b84cc34707c28ca0db8d24f046ec34e8c25d (diff)
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 <luca.boccassi@microsoft.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/sqfs/read_tree.c3
1 files changed, 3 insertions, 0 deletions
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;