39 lines
1.1 KiB
Diff
39 lines
1.1 KiB
Diff
|
From 320e86747a32e4d46d24ee4b64493741c161da50 Mon Sep 17 00:00:00 2001
|
||
|
From: Peter Jones <pjones@redhat.com>
|
||
|
Date: Sun, 19 Jul 2020 16:08:08 -0400
|
||
|
Subject: [PATCH] emu: Make grub_free(NULL) safe
|
||
|
MIME-Version: 1.0
|
||
|
Content-Type: text/plain; charset=UTF-8
|
||
|
Content-Transfer-Encoding: 8bit
|
||
|
|
||
|
The grub_free() implementation in grub-core/kern/mm.c safely handles
|
||
|
NULL pointers, and code at many places depends on this. We don't know
|
||
|
that the same is true on all host OSes, so we need to handle the same
|
||
|
behavior in grub-emu's implementation.
|
||
|
|
||
|
Signed-off-by: Peter Jones <pjones@redhat.com>
|
||
|
Reviewed-by: Darren Kenny <darren.kenny@oracle.com>
|
||
|
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
||
|
Signed-off-by: Stefan Sørensen <stefan.sorensen@spectralink.com>
|
||
|
---
|
||
|
grub-core/kern/emu/mm.c | 3 ++-
|
||
|
1 file changed, 2 insertions(+), 1 deletion(-)
|
||
|
|
||
|
diff --git a/grub-core/kern/emu/mm.c b/grub-core/kern/emu/mm.c
|
||
|
index 145b01d37..4d1046a21 100644
|
||
|
--- a/grub-core/kern/emu/mm.c
|
||
|
+++ b/grub-core/kern/emu/mm.c
|
||
|
@@ -60,7 +60,8 @@ grub_zalloc (grub_size_t size)
|
||
|
void
|
||
|
grub_free (void *ptr)
|
||
|
{
|
||
|
- free (ptr);
|
||
|
+ if (ptr)
|
||
|
+ free (ptr);
|
||
|
}
|
||
|
|
||
|
void *
|
||
|
--
|
||
|
2.26.2
|
||
|
|