From be8da02c89d9e28452864b03c46e2c4b11774432 Mon Sep 17 00:00:00 2001 From: Sean Brogan Date: Mon, 22 Apr 2024 16:57:36 -0700 Subject: [PATCH] Fix bad CodeQL fix - REBASE with PR 6024 --- .../Library/UefiBootManagerLib/BmBoot.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c b/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c index a3fc3b6a384..c75aaf1f61c 100644 --- a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c +++ b/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c @@ -718,16 +718,21 @@ BmExpandFileDevicePath ( ((MediaType == 2) && (BlockIo == NULL)) ) { + NextFullPath = AppendDevicePath (DevicePathFromHandle (Handles[Index]), FilePath); + if (NextFullPath == NULL) { + continue; + } + if (GetNext) { + //this is the break/exit condition. Occurs on first if FullPath input parameter was NULL + //or on the next loop after input parameter FullPath matches NextFullPath. + //NextFullPath will not be NULL so outer loop is broken too break; } - NextFullPath = AppendDevicePath (DevicePathFromHandle (Handles[Index]), FilePath); - if (NextFullPath != NULL) { - GetNext = (BOOLEAN)(CompareMem (NextFullPath, FullPath, GetDevicePathSize (NextFullPath)) == 0); - FreePool (NextFullPath); - NextFullPath = NULL; - } + GetNext = (BOOLEAN)(CompareMem (NextFullPath, FullPath, GetDevicePathSize (NextFullPath)) == 0); + FreePool (NextFullPath); + NextFullPath = NULL; } }