ShellPkg/UefiHandleParsingLib: Fix memory leak
[mirror_edk2.git] / ShellPkg / Library / UefiHandleParsingLib / UefiHandleParsingLib.c
index c368d8cb21d1bdd65a557bcd20cc982135708c30..da1d92fd1717b7101ae40dabf3920d1578918ad7 100644 (file)
@@ -2331,7 +2331,9 @@ ConvertHandleIndexToHandle(
       // Verify that LinkWalker->TheHandle is valid handle\r
       //\r
       Status = gBS->ProtocolsPerHandle(ListWalker->TheHandle, &ProtocolBuffer, &ProtocolCount);\r
-      if (EFI_ERROR (Status)) {\r
+      if (!EFI_ERROR (Status)) {\r
+        FreePool (ProtocolBuffer);\r
+      } else {\r
         //\r
         // TheHandle is not valid, so do not add to handle list\r
         //\r