From 9c80754151a398650d7467a94b6c0ca6160f21f8 Mon Sep 17 00:00:00 2001 From: Darren Kenny Date: Thu, 26 Nov 2020 12:53:10 +0000 Subject: [PATCH] loader/xnu: Fix memory leak he 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 Reference: http://git.savannah.gnu.org/cgit/grub.git/commit/?id=bcb59ece3263d118510c4440c4da0950f224bb7f Signed-off-by: Darren Kenny Reviewed-by: Daniel Kiper --- grub-core/loader/xnu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/loader/xnu.c b/grub-core/loader/xnu.c index 36481d8..9d40908 100644 --- a/grub-core/loader/xnu.c +++ b/grub-core/loader/xnu.c @@ -1392,9 +1392,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) -- 2.19.1