From: Lidong Chen Date: Thu, 27 Mar 2025 17:56:32 +0000 (+0000) Subject: lib/reloacator: Fix memory leaks X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1d005944754b7298b6df3debddb6abae22745265;p=thirdparty%2Fgrub.git lib/reloacator: Fix memory leaks Fix memory leaks in grub_relocator_alloc_chunk_align(). Fixes: CID 473844 Signed-off-by: Lidong Chen Reviewed-by: Vladimir Serbinenko Reviewed-by: Daniel Kiper --- diff --git a/grub-core/lib/relocator.c b/grub-core/lib/relocator.c index e0478ae5b..3306a1bb7 100644 --- a/grub-core/lib/relocator.c +++ b/grub-core/lib/relocator.c @@ -1440,6 +1440,7 @@ grub_relocator_alloc_chunk_align (struct grub_relocator *rel, break; } + grub_free (ctx.chunk); return grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory")); } while (0); @@ -1456,7 +1457,10 @@ grub_relocator_alloc_chunk_align (struct grub_relocator *rel, grub_mmap_iterate (grub_relocator_alloc_chunk_align_iter, &ctx); #endif if (!ctx.found) - return grub_error (GRUB_ERR_BAD_OS, "couldn't find suitable memory target"); + { + grub_free (ctx.chunk); + return grub_error (GRUB_ERR_BAD_OS, "couldn't find suitable memory target"); + } } while (1) {