Blame SOURCES/0422-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
3efed6
index b33a384321c..16bfa7cec72 100644
9723a8
--- a/grub-core/loader/xnu.c
9723a8
+++ b/grub-core/loader/xnu.c
3efed6
@@ -1392,9 +1392,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)