diff --git a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c index c368d8cb21..da1d92fd17 100644 --- a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c +++ b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c @@ -2331,7 +2331,9 @@ ConvertHandleIndexToHandle( // Verify that LinkWalker->TheHandle is valid handle // Status = gBS->ProtocolsPerHandle(ListWalker->TheHandle, &ProtocolBuffer, &ProtocolCount); - if (EFI_ERROR (Status)) { + if (!EFI_ERROR (Status)) { + FreePool (ProtocolBuffer); + } else { // // TheHandle is not valid, so do not add to handle list //