From 2880e665ab3c72ce029cc31289c61ae72fbe667a Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 21 Jun 2018 18:48:21 +0200 Subject: [PATCH] efi: explicity check for NULL in FreePoolp() Firmware implementations are generally pretty bad, hence let's better add an explicit check for NULL before invokin FreePool(), in particular is it doesn't appear to be documented whether FreePool() is supposed to be happy with NULL. --- src/boot/efi/util.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/boot/efi/util.h b/src/boot/efi/util.h index 6d1a52f6188..9921e8bc0a5 100644 --- a/src/boot/efi/util.h +++ b/src/boot/efi/util.h @@ -33,7 +33,12 @@ CHAR16 *stra_to_str(CHAR8 *stra); EFI_STATUS file_read(EFI_FILE_HANDLE dir, CHAR16 *name, UINTN off, UINTN size, CHAR8 **content, UINTN *content_size); static inline void FreePoolp(void *p) { - FreePool(*(void**) p); + void *q = *(void**) p; + + if (!q) + return; + + FreePool(q); } #define _cleanup_(x) __attribute__((cleanup(x)))