Skip to content

Commit

Permalink
Merge pull request #261 from eriksjolund/add-missing-node-unref
Browse files Browse the repository at this point in the history
lib: Add missing lcfs_node_unref()
  • Loading branch information
cgwalters authored Mar 19, 2024
2 parents 9c393a4 + 4e0b147 commit d5ffbeb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 3 additions & 1 deletion libcomposefs/lcfs-writer-erofs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 4 additions & 1 deletion libcomposefs/lcfs-writer.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
}
Expand Down

0 comments on commit d5ffbeb

Please sign in to comment.