代码拉取完成,页面将自动刷新
From 1512dc33b36ad0feff9dbdcfe38e6d2acdcb38a0 Mon Sep 17 00:00:00 2001
From: Li Jinlin <[email protected]>
Date: Tue, 29 Mar 2022 11:10:19 +0800
Subject: [PATCH 6/6] fat_clobber: set boot_sector = NULL and free boot_sector
after failed of fat_boot_sector_read
When fat_boot_sector_read() returns failure, boot_sector may have
allocated memory, and memory leak will occur
Signed-off-by: Wu Guanghao <[email protected]>
Signed-off-by: Li Jinlin <[email protected]>
---
libparted/fs/r/fat/fat.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/libparted/fs/r/fat/fat.c b/libparted/fs/r/fat/fat.c
index 396494a..33a4284 100644
--- a/libparted/fs/r/fat/fat.c
+++ b/libparted/fs/r/fat/fat.c
@@ -117,11 +117,13 @@ fat_set_frag_sectors (PedFileSystem* fs, PedSector frag_sectors)
int
fat_clobber (PedGeometry* geom)
{
- FatBootSector *boot_sector;
+ FatBootSector *boot_sector = NULL;
int ok;
- if (!fat_boot_sector_read (&boot_sector, geom))
+ if (!fat_boot_sector_read (&boot_sector, geom)) {
+ free(boot_sector);
return 1;
+ }
boot_sector->system_id[0] = 0;
boot_sector->boot_sign = 0;
--
2.27.0
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。