nalika / rpms / grub2

Forked from rpms/grub2 2 years ago
Clone

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

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