Skip to content

Commit 79fee36

Browse files
committed
libbtrfs: handle memory allocation errors when searching uuids
CodeQL reports missing error handling, so fix it. Signed-off-by: David Sterba <dsterba@suse.com>
1 parent 0698142 commit 79fee36

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

libbtrfs/send-utils.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -777,8 +777,17 @@ int subvol_uuid_search_init(int mnt_fd, struct subvol_uuid_search *s)
777777
goto out;
778778
}
779779
path = strdup(path_buf);
780+
if (!path) {
781+
ret = -ENOMEM;
782+
goto out;
783+
}
780784

781785
si = calloc(1, sizeof(*si));
786+
if (!si) {
787+
free(path);
788+
ret = -ENOMEM;
789+
goto out;
790+
}
782791
si->root_id = btrfs_search_header_objectid(sh);
783792
memcpy(si->uuid, root_item.uuid,
784793
BTRFS_UUID_SIZE);

0 commit comments

Comments
 (0)