From 4e0b147d589ca3918e76c977d6af0df0a75025f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20Sj=C3=B6lund?= Date: Sun, 17 Mar 2024 11:01:06 +0100 Subject: [PATCH] lib: Add missing lcfs_node_unref() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Erik Sjölund --- libcomposefs/lcfs-writer-erofs.c | 4 +++- libcomposefs/lcfs-writer.c | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/libcomposefs/lcfs-writer-erofs.c b/libcomposefs/lcfs-writer-erofs.c index c1b58c2..10aae28 100644 --- a/libcomposefs/lcfs-writer-erofs.c +++ b/libcomposefs/lcfs-writer-erofs.c @@ -1211,8 +1211,10 @@ static int add_overlay_whiteouts(struct lcfs_node_s *root) } res = lcfs_node_add_child(root, child, name); - if (res < 0) + if (res < 0) { + lcfs_node_unref(child); return res; + } } return 0; diff --git a/libcomposefs/lcfs-writer.c b/libcomposefs/lcfs-writer.c index ea78385..2eba4e5 100644 --- a/libcomposefs/lcfs-writer.c +++ b/libcomposefs/lcfs-writer.c @@ -1212,8 +1212,10 @@ static struct lcfs_node_s *_lcfs_node_clone_deep(struct lcfs_node_s *node, if (new_child == NULL) return NULL; - if (lcfs_node_add_child(new, new_child, child->name) < 0) + if (lcfs_node_add_child(new, new_child, child->name) < 0) { + lcfs_node_unref(new_child); return NULL; + } } return steal_pointer(&new); @@ -1349,6 +1351,7 @@ struct lcfs_node_s *lcfs_build(int dirfd, const char *fname, int buildflags, r = lcfs_node_add_child(node, n, de->d_name); if (r < 0) { errsv = errno; + lcfs_node_unref(n); goto fail; } }