dcavalca / rpms / grub2

Forked from rpms/grub2 3 years ago
Clone

Blame SOURCES/0302-emu-make-grub_free-NULL-safe.patch

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