]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
loader/xnu: Fix memory leak
authorLidong Chen <lidong.chen@oracle.com>
Thu, 27 Mar 2025 17:56:35 +0000 (17:56 +0000)
committerDaniel Kiper <daniel.kiper@oracle.com>
Fri, 4 Apr 2025 17:37:34 +0000 (19:37 +0200)
In grub_xnu_load_kext_from_dir(), when the call to grub_device_open()
failed, it simply cleaned up previously allocated memory and returned
GRUB_ERR_NONE. However, it neglected to free ctx->newdirname which is
allocated before the call to grub_device_open().

Fixes: CID 473859
Signed-off-by: Lidong Chen <lidong.chen@oracle.com>
Reviewed-by: Vladimir Serbinenko <phcoder@gmail.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
grub-core/loader/xnu.c

index 4cca55df92db86eb1deda86c79ab920e59e6d6a7..80831386e3bff28341fc460cadb753fa1b95d9e6 100644 (file)
@@ -1258,6 +1258,7 @@ grub_xnu_load_kext_from_dir (char *dirname, const char *osbundlerequired,
       grub_device_close (dev);
     }
   grub_free (device_name);
+  grub_free (ctx.newdirname);
 
   return GRUB_ERR_NONE;
 }