parted/SOURCES/0017-libparted-Fix-possible-memory-leaks.patch

63 lines
2.2 KiB
Diff
Raw Normal View History

2019-05-07 13:06:40 +00:00
From c01a30a6821b243cb0f497b73bb5a7b7465b6aca Mon Sep 17 00:00:00 2001
From: Amarnath Valluri <amarnath.valluri@intel.com>
Date: Tue, 4 Aug 2015 13:04:45 +0300
Subject: [PATCH 17/18] libparted: Fix possible memory leaks
* libparted/fs/r/fat/resize.c(fat_convert_directory): Possible leak
of sub_old_dir_trav or sub_new_dir_trav in error case.
* libparted/fs/r/fat/resize.c(fat_construct_converted_tree ): Possible
leak of new_trav_info or old_trav_info in error case.
Signed-off-by: Amarnath Valluri <amarnath.valluri@intel.com>
Signed-off-by: Brian C. Lane <bcl@redhat.com>
(cherry picked from commit 4886bad13dd011ff56e1c46ff29e8067778c16fd)
---
libparted/fs/r/fat/resize.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/libparted/fs/r/fat/resize.c b/libparted/fs/r/fat/resize.c
index 919acf0..b512576 100644
--- a/libparted/fs/r/fat/resize.c
+++ b/libparted/fs/r/fat/resize.c
@@ -177,10 +177,13 @@ fat_convert_directory (FatOpContext* ctx, FatTraverseInfo* old_trav,
&& old_dir_entry->name [0] != '.') {
sub_old_dir_trav
= fat_traverse_directory (old_trav, old_dir_entry);
+ if (!sub_old_dir_trav) return 0;
sub_new_dir_trav
= fat_traverse_directory (new_trav, new_dir_entry);
- if (!sub_old_dir_trav || !sub_new_dir_trav)
+ if (!sub_new_dir_trav) {
+ fat_traverse_complete (sub_old_dir_trav);
return 0;
+ }
if (!fat_convert_directory (ctx, sub_old_dir_trav,
sub_new_dir_trav))
@@ -315,17 +318,21 @@ fat_construct_converted_tree (FatOpContext* ctx)
if (new_fs_info->fat_type == FAT_TYPE_FAT32) {
new_trav_info = fat_traverse_begin (ctx->new_fs,
new_fs_info->root_cluster, "\\");
+ if (!new_trav_info) return 0;
old_trav_info = fat_traverse_begin (ctx->old_fs, FAT_ROOT,
"\\");
} else {
fat_clear_root_dir (ctx->new_fs);
new_trav_info = fat_traverse_begin (ctx->new_fs, FAT_ROOT,
"\\");
+ if (!new_trav_info) return 0;
old_trav_info = fat_traverse_begin (ctx->old_fs,
old_fs_info->root_cluster, "\\");
}
- if (!new_trav_info || !old_trav_info)
+ if (!old_trav_info) {
+ fat_traverse_complete (new_trav_info);
return 0;
+ }
if (!fat_convert_directory (ctx, old_trav_info, new_trav_info))
return 0;
return 1;
--
2.4.3