ShellPkg/UefiHandleParsingLib: Fix memory leak
authorRuiyu Ni <ruiyu.ni@intel.com>
Tue, 2 May 2017 07:55:04 +0000 (15:55 +0800)
committerRuiyu Ni <ruiyu.ni@intel.com>
Wed, 3 May 2017 02:41:03 +0000 (10:41 +0800)
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Signed-off-by: Chen A Chen <chen.a.chen@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
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
       // 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
         //\r
         // TheHandle is not valid, so do not add to handle list\r
         //\r