Fix several memory leaks.
* grub-core/fs/btrfs.c (grub_btrfs_dir): Fix memory leak. * grub-core/fs/cpio.c (grub_cpio_find_file): Likewise. (grub_cpio_dir): Likewise. * grub-core/fs/fat.c (grub_fat_label): Likewise. * grub-core/fs/jfs.c (grub_jfs_label): Likewise. * grub-core/fs/romfs.c (grub_romfs_close): Likewise. (grub_romfs_label): Likewise. * grub-core/fs/squash4.c (squash_mount): Use zalloc for safety. (squash_unmount): New function. (grub_squash_dir): Fix memory leak. (grub_squash_open): Likewise. (grub_squash_read): Likewise. (grub_squash_mtime): Likewise. * grub-core/fs/xfs.c (grub_xfs_open): Likewise. * grub-core/fs/zfs/zfs.c (check_pool_label): Likewise. * util/grub-fstest.c (fstest): Likewise.
This commit is contained in:
parent
57b0125004
commit
8a5a3a5b5a
10 changed files with 84 additions and 22 deletions
|
@ -1415,22 +1415,28 @@ grub_btrfs_dir (grub_device_t device, const char *path,
|
|||
|
||||
err = find_path (data, path, &key_in, &tree, &type);
|
||||
if (err)
|
||||
return err;
|
||||
{
|
||||
grub_btrfs_unmount (data);
|
||||
return err;
|
||||
}
|
||||
if (type != GRUB_BTRFS_DIR_ITEM_TYPE_DIRECTORY)
|
||||
return grub_error (GRUB_ERR_BAD_FILE_TYPE, "not a directory");
|
||||
{
|
||||
grub_btrfs_unmount (data);
|
||||
return grub_error (GRUB_ERR_BAD_FILE_TYPE, "not a directory");
|
||||
}
|
||||
|
||||
err = lower_bound (data, &key_in, &key_out, tree, &elemaddr, &elemsize, &desc);
|
||||
if (err)
|
||||
return err;
|
||||
{
|
||||
grub_btrfs_unmount (data);
|
||||
return err;
|
||||
}
|
||||
if (key_out.type != GRUB_BTRFS_ITEM_TYPE_DIR_ITEM
|
||||
|| key_out.object_id != key_in.object_id)
|
||||
{
|
||||
r = next (data, &desc, &elemaddr, &elemsize, &key_out);
|
||||
if (r <= 0)
|
||||
{
|
||||
free_iterator (&desc);
|
||||
return -r;
|
||||
}
|
||||
goto out;
|
||||
}
|
||||
do
|
||||
{
|
||||
|
@ -1448,14 +1454,17 @@ grub_btrfs_dir (grub_device_t device, const char *path,
|
|||
direl = grub_malloc (allocated + 1);
|
||||
if (!direl)
|
||||
{
|
||||
free_iterator (&desc);
|
||||
return grub_errno;
|
||||
r = -grub_errno;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
err = grub_btrfs_read_logical (data, elemaddr, direl, elemsize);
|
||||
if (err)
|
||||
return err;
|
||||
{
|
||||
r = -err;
|
||||
break;
|
||||
}
|
||||
|
||||
for (cdirel = direl;
|
||||
(grub_uint8_t *) cdirel - (grub_uint8_t *) direl
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue