]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
loader/xnu: Fix memory leak
authorDarren Kenny <darren.kenny@oracle.com>
Thu, 26 Nov 2020 12:53:10 +0000 (12:53 +0000)
committerDaniel Kiper <daniel.kiper@oracle.com>
Tue, 2 Mar 2021 14:54:17 +0000 (15:54 +0100)
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

index 44fd5a979a5760a34ac30c02c78a9db8c77706ab..eb1446251ddacdc759b87bc6aa0140979a5cfe44 100644 (file)
@@ -1391,9 +1391,9 @@ grub_xnu_fill_devicetree (void)
     name[len] = 0;
 
     curvalue = grub_xnu_create_value (curkey, name);
+    grub_free (name);
     if (!curvalue)
       return grub_errno;
-    grub_free (name);
    
     data = grub_malloc (grub_strlen (var->value) + 1);
     if (!data)