nalika / rpms / grub2

Forked from rpms/grub2 2 years ago
Clone

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

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