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

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