7 Star 0 Fork 26

src-openEuler/parted

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0009-fat_clobber-set-boot_sector-NULL-and-free-boot_secto.patch 1.12 KB
一键复制 编辑 原始数据 按行查看 历史
Li Jinlin 提交于 2022-03-29 11:17 . fix memory leak in libparted
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
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/src-openeuler/parted.git
[email protected]:src-openeuler/parted.git
src-openeuler
parted
parted
master

搜索帮助