b1bcb2
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
c4e390
From: Peter Jones <pjones@redhat.com>
c4e390
Date: Sun, 19 Jul 2020 16:08:08 -0400
b1bcb2
Subject: [PATCH] emu: make grub_free(NULL) safe
c4e390
c4e390
The grub_free() implementation in kern/mm.c safely handles NULL
c4e390
pointers, and code at many places depends on this.  We don't know that
c4e390
the same is true on all host OSes, so we need to handle the same
c4e390
behavior in grub-emu's implementation.
c4e390
c4e390
Signed-off-by: Peter Jones <pjones@redhat.com>
c4e390
Reviewed-by: Darren Kenny <darren.kenny@oracle.com>
c4e390
Upstream-commit-id: 96bb109e658
c4e390
---
c4e390
 grub-core/kern/emu/mm.c | 3 ++-
c4e390
 1 file changed, 2 insertions(+), 1 deletion(-)
c4e390
c4e390
diff --git a/grub-core/kern/emu/mm.c b/grub-core/kern/emu/mm.c
c4e390
index 145b01d3719..4d1046a219e 100644
c4e390
--- a/grub-core/kern/emu/mm.c
c4e390
+++ b/grub-core/kern/emu/mm.c
c4e390
@@ -60,7 +60,8 @@ grub_zalloc (grub_size_t size)
c4e390
 void
c4e390
 grub_free (void *ptr)
c4e390
 {
c4e390
-  free (ptr);
c4e390
+  if (ptr)
c4e390
+    free (ptr);
c4e390
 }
c4e390
 
c4e390
 void *