summaryrefslogtreecommitdiff
path: root/libbtrfsutil
diff options
context:
space:
mode:
authorOmar Sandoval <osandov@fb.com>2018-03-29 00:53:54 -0700
committerDavid Sterba <dsterba@suse.com>2018-03-30 22:53:57 +0200
commitf5dd778f5299088f89d380ce922a84d77a98b9d6 (patch)
treee6483f7dc00525cd12e827201f3aee3d5773351e /libbtrfsutil
parentc41c5b1562c5a628f164a1d3d3d19a9c1f728bdf (diff)
libbtrfsutil: fix memory leak in deleted_subvolumes()
If we fail to reallocate the ID array, we still need to free it. Signed-off-by: Omar Sandoval <osandov@fb.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'libbtrfsutil')
-rw-r--r--libbtrfsutil/subvolume.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/libbtrfsutil/subvolume.c b/libbtrfsutil/subvolume.c
index d6c0ced..867b3e1 100644
--- a/libbtrfsutil/subvolume.c
+++ b/libbtrfsutil/subvolume.c
@@ -1353,8 +1353,10 @@ PUBLIC enum btrfs_util_error btrfs_util_deleted_subvolumes_fd(int fd,
new_capacity = capacity ? capacity * 2 : 1;
new_ids = reallocarray(*ids, new_capacity,
sizeof(**ids));
- if (!new_ids)
- return BTRFS_UTIL_ERROR_NO_MEMORY;
+ if (!new_ids) {
+ err = BTRFS_UTIL_ERROR_NO_MEMORY;
+ goto out;
+ }
*ids = new_ids;
capacity = new_capacity;