代码拉取完成,页面将自动刷新
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
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。