7 Star 0 Fork 25

src-openEuler/parted

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0007-fat_op_context_new-free-ctx-remap-and-goto-correct-l.patch 1.61 KB
一键复制 编辑 原始数据 按行查看 历史
Li Jinlin 提交于 2022-03-29 11:17 . fix memory leak in libparted
From fa8544b4229e19679db070c31969c9739f702fd0 Mon Sep 17 00:00:00 2001
From: Li Jinlin <[email protected]>
Date: Tue, 29 Mar 2022 11:07:33 +0800
Subject: [PATCH 4/6] fat_op_context_new: free ctx->remap and goto correct
label to avoid memleak
When calc_deltas returns an error, need to release ctx->remap,
and eed to jump to the correct label to release ctx, otherwise
there will be memory leaks
Signed-off-by: Wu Guanghao <[email protected]>
Signed-off-by: Li Jinlin <[email protected]>
---
libparted/fs/r/fat/context.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/libparted/fs/r/fat/context.c b/libparted/fs/r/fat/context.c
index 5ca154c..fce77af 100644
--- a/libparted/fs/r/fat/context.c
+++ b/libparted/fs/r/fat/context.c
@@ -86,9 +86,9 @@ fat_op_context_new (PedFileSystem* new_fs, PedFileSystem* old_fs)
ctx->frag_sectors = PED_MIN (old_fs_info->cluster_sectors,
new_fs_info->cluster_sectors);
if (!fat_set_frag_sectors (new_fs, ctx->frag_sectors))
- goto error;
+ goto error_free_ctx;
if (!fat_set_frag_sectors (old_fs, ctx->frag_sectors))
- goto error;
+ goto error_free_ctx;
ctx->buffer_frags = old_fs_info->buffer_sectors / ctx->frag_sectors;
ctx->buffer_map = (FatFragment*) ped_malloc (sizeof (FatFragment)
@@ -104,10 +104,12 @@ fat_op_context_new (PedFileSystem* new_fs, PedFileSystem* old_fs)
ctx->new_fs = new_fs;
ctx->old_fs = old_fs;
if (!calc_deltas (ctx))
- goto error_free_buffer_map;
+ goto error_free_remap;
return ctx;
+error_free_remap:
+ free(ctx->remap);
error_free_buffer_map:
free (ctx->buffer_map);
error_free_ctx:
--
2.27.0
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/src-openeuler/parted.git
[email protected]:src-openeuler/parted.git
src-openeuler
parted
parted
master

搜索帮助