nalika / rpms / grub2

Forked from rpms/grub2 2 years ago
Clone

Blame SOURCES/0367-loader-xnu-Fix-memory-leak.patch

9723a8
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
9723a8
From: Darren Kenny <darren.kenny@oracle.com>
9723a8
Date: Thu, 26 Nov 2020 12:53:10 +0000
9723a8
Subject: [PATCH] loader/xnu: Fix memory leak
9723a8
9723a8
The code here is finished with the memory stored in name, but it only
9723a8
frees it if there curvalue is valid, while it could actually free it
9723a8
regardless.
9723a8
9723a8
The fix is a simple relocation of the grub_free() to before the test
9723a8
of curvalue.
9723a8
9723a8
Fixes: CID 96646
9723a8
9723a8
Signed-off-by: Darren Kenny <darren.kenny@oracle.com>
9723a8
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
9723a8
---
9723a8
 grub-core/loader/xnu.c | 4 ++--
9723a8
 1 file changed, 2 insertions(+), 2 deletions(-)
9723a8
9723a8
diff --git a/grub-core/loader/xnu.c b/grub-core/loader/xnu.c
9723a8
index 0c4b33250fb..2adeac8a549 100644
9723a8
--- a/grub-core/loader/xnu.c
9723a8
+++ b/grub-core/loader/xnu.c
9723a8
@@ -1383,9 +1383,9 @@ grub_xnu_fill_devicetree (void)
9723a8
     name[len] = 0;
9723a8
 
9723a8
     curvalue = grub_xnu_create_value (curkey, name);
9723a8
-    if (!curvalue)
9723a8
-      return grub_errno;
9723a8
     grub_free (name);
9723a8
+    if (!curvalue)
9723a8
+      return grub_errno;
9723a8
    
9723a8
     data = grub_malloc (grub_strlen (var->value) + 1);
9723a8
     if (!data)