From: Lennart Poettering Date: Mon, 20 Sep 2021 12:06:23 +0000 (+0200) Subject: boot: ReallocatePool() supports NULL pointers as first argument X-Git-Tag: v250-rc1~649^2~2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=04394aa185de1dcf76551f3fb7159b755b34acb3;p=thirdparty%2Fsystemd.git boot: ReallocatePool() supports NULL pointers as first argument 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 --- diff --git a/src/boot/efi/boot.c b/src/boot/efi/boot.c index 106fda925cb..074a8565982 100644 --- a/src/boot/efi/boot.c +++ b/src/boot/efi/boot.c @@ -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; }