From: Lennart Poettering Date: Thu, 21 Jun 2018 16:48:21 +0000 (+0200) Subject: efi: explicity check for NULL in FreePoolp() X-Git-Tag: v240~522^2~12 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2880e665ab3c72ce029cc31289c61ae72fbe667a;p=thirdparty%2Fsystemd.git 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. --- 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)))