]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
boot: ReallocatePool() supports NULL pointers as first argument
authorLennart Poettering <lennart@poettering.net>
Mon, 20 Sep 2021 12:06:23 +0000 (14:06 +0200)
committerLennart Poettering <lennart@poettering.net>
Mon, 20 Sep 2021 20:18:17 +0000 (22:18 +0200)
Just like userspace realloc() the EFIlib ReallocatePool() function is
happy to use a NULL pointer as input, in which case it is equivalent to
AllocatePool(). See:

https://github.com/vathpela/gnu-efi/blob/269ef9dbc77ebec2723e0e6ae082bbca9516f5f1/lib/misc.c#L57

src/boot/efi/boot.c

index 106fda925cbc92283d01d0f73a2156170ed94a69..074a85659829d48eb473cf2692ffaf21d97a0c37 100644 (file)
@@ -912,14 +912,11 @@ static VOID config_add_entry(Config *config, ConfigEntry *entry) {
         assert(entry);
 
         if ((config->entry_count & 15) == 0) {
-                UINTN i;
-
-                i = config->entry_count + 16;
-                if (config->entry_count == 0)
-                        config->entries = AllocatePool(sizeof(VOID *) * i);
-                else
-                        config->entries = ReallocatePool(config->entries,
-                                                         sizeof(VOID *) * config->entry_count, sizeof(VOID *) * i);
+                UINTN i = config->entry_count + 16;
+                config->entries = ReallocatePool(
+                                config->entries,
+                                sizeof(VOID *) * config->entry_count,
+                                sizeof(VOID *) * i);
         }
         config->entries[config->entry_count++] = entry;
 }