2021-03-02 18:56:20 +00:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
2020-07-29 17:15:26 +00:00
|
|
|
From: Peter Jones <pjones@redhat.com>
|
|
|
|
Date: Sun, 19 Jul 2020 16:08:08 -0400
|
2021-03-02 18:56:20 +00:00
|
|
|
Subject: [PATCH] emu: make grub_free(NULL) safe
|
2020-07-29 17:15:26 +00:00
|
|
|
|
|
|
|
The grub_free() implementation in 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>
|
|
|
|
Upstream-commit-id: 96bb109e658
|
|
|
|
---
|
|
|
|
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
|
2022-05-10 07:20:45 +00:00
|
|
|
index 145b01d37..4d1046a21 100644
|
2020-07-29 17:15:26 +00:00
|
|
|
--- 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 *
|