]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg/UefiHiiLib: Add error handling codes when AllocatePool fail
authorBi, Dandan <C:/Program Files (x86)/Git/o=Intel/ou=Exchange Administrative Group (FYDIBOHF23SPDLT)/cn=Recipients/cn=Bi, Dandan08b>
Tue, 5 Jul 2016 03:19:22 +0000 (11:19 +0800)
committerHao Wu <hao.a.wu@intel.com>
Wed, 6 Jul 2016 08:22:52 +0000 (16:22 +0800)
Cc: Eric Dong <eric.dong@intel.com>
Cc: Hao Wu <hao.a.wu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
Reviewed-by: Hao Wu <hao.a.wu@intel.com>
MdeModulePkg/Library/UefiHiiLib/HiiLib.c

index 74ccd0211741e2469e1e9ada8d48e721190ecfef..afd9985654069a0e00862cec7a02d91f7df13e97 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   HII Library implementation that uses DXE protocols and services.\r
 \r
-  Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
@@ -465,10 +465,19 @@ HiiGetFormSetFromHiiHandle(
 \r
       if (FormSetBuffer != NULL){\r
         TempBuffer = AllocateCopyPool (TempSize + ((EFI_IFR_OP_HEADER *) OpCodeData)->Length, FormSetBuffer);\r
-        CopyMem (TempBuffer + TempSize,  OpCodeData, ((EFI_IFR_OP_HEADER *) OpCodeData)->Length);\r
         FreePool(FormSetBuffer);\r
+        FormSetBuffer = NULL;\r
+        if (TempBuffer == NULL) {\r
+          Status = EFI_OUT_OF_RESOURCES;\r
+          goto Done;\r
+        }\r
+        CopyMem (TempBuffer + TempSize,  OpCodeData, ((EFI_IFR_OP_HEADER *) OpCodeData)->Length);\r
       } else {\r
         TempBuffer = AllocateCopyPool (TempSize + ((EFI_IFR_OP_HEADER *) OpCodeData)->Length, OpCodeData);\r
+        if (TempBuffer == NULL) {\r
+          Status = EFI_OUT_OF_RESOURCES;\r
+          goto Done;\r
+        }\r
       }\r
       TempSize += ((EFI_IFR_OP_HEADER *) OpCodeData)->Length;\r
       FormSetBuffer = TempBuffer;\r
@@ -480,6 +489,7 @@ HiiGetFormSetFromHiiHandle(
       break;\r
     }\r
   }\r
+Done:\r
   FreePool (HiiPackageList);\r
 \r
   *BufferSize = TempSize;\r