1 Star 0 Fork 48

fe.zhang/grub2

forked from src-anolis-os/grub2 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0422-loader-xnu-Fix-memory-leak.patch 1.09 KB
一键复制 编辑 原始数据 按行查看 历史
geliwei 提交于 2022-04-13 15:15 . update to grub2-2.02-120.el8.src.rpm
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Darren Kenny <darren.kenny@oracle.com>
Date: Thu, 26 Nov 2020 12:53:10 +0000
Subject: [PATCH] loader/xnu: Fix memory leak
The code here is finished with the memory stored in name, but it only
frees it if there curvalue is valid, while it could actually free it
regardless.
The fix is a simple relocation of the grub_free() to before the test
of curvalue.
Fixes: CID 96646
Signed-off-by: Darren Kenny <darren.kenny@oracle.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
---
grub-core/loader/xnu.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/grub-core/loader/xnu.c b/grub-core/loader/xnu.c
index b33a38432..16bfa7cec 100644
--- a/grub-core/loader/xnu.c
+++ b/grub-core/loader/xnu.c
@@ -1392,9 +1392,9 @@ grub_xnu_fill_devicetree (void)
name[len] = 0;
curvalue = grub_xnu_create_value (curkey, name);
- if (!curvalue)
- return grub_errno;
grub_free (name);
+ if (!curvalue)
+ return grub_errno;
data = grub_malloc (grub_strlen (var->value) + 1);
if (!data)
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/fe_zhang/grub2.git
git@gitee.com:fe_zhang/grub2.git
fe_zhang
grub2
grub2
a8

搜索帮助