]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
efi: explicity check for NULL in FreePoolp()
authorLennart Poettering <lennart@poettering.net>
Thu, 21 Jun 2018 16:48:21 +0000 (18:48 +0200)
committerLennart Poettering <lennart@poettering.net>
Tue, 16 Oct 2018 14:44:34 +0000 (16:44 +0200)
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

index 6d1a52f6188820303139accdb00112feaface1d7..9921e8bc0a58aa40c6d61b37f705e59cd6f1a0b6 100644 (file)
@@ -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)))