grub2/SOURCES/0422-loader-xnu-Fix-memory-leak.patch

37 lines
1.1 KiB
Diff
Raw Normal View History

2021-03-02 18:56:20 +00:00
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
2022-05-10 07:20:45 +00:00
index b33a38432..16bfa7cec 100644
2021-03-02 18:56:20 +00:00
--- a/grub-core/loader/xnu.c
+++ b/grub-core/loader/xnu.c
2021-05-18 06:38:48 +00:00
@@ -1392,9 +1392,9 @@ grub_xnu_fill_devicetree (void)
2021-03-02 18:56:20 +00:00
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)