Cc: Eric Dong <[email protected]>
Cc: Hao Wu <[email protected]>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Dandan Bi <[email protected]>
---
 MdeModulePkg/Library/UefiHiiLib/HiiLib.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/MdeModulePkg/Library/UefiHiiLib/HiiLib.c 
b/MdeModulePkg/Library/UefiHiiLib/HiiLib.c
index 74ccd02..afd9985 100644
--- a/MdeModulePkg/Library/UefiHiiLib/HiiLib.c
+++ b/MdeModulePkg/Library/UefiHiiLib/HiiLib.c
@@ -1,9 +1,9 @@
 /** @file
   HII Library implementation that uses DXE protocols and services.
 
-  Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD 
License
   which accompanies this distribution.  The full text of the license may be 
found at
   http://opensource.org/licenses/bsd-license.php
 
@@ -463,14 +463,23 @@ HiiGetFormSetFromHiiHandle(
         continue;
       }
 
       if (FormSetBuffer != NULL){
         TempBuffer = AllocateCopyPool (TempSize + ((EFI_IFR_OP_HEADER *) 
OpCodeData)->Length, FormSetBuffer);
-        CopyMem (TempBuffer + TempSize,  OpCodeData, ((EFI_IFR_OP_HEADER *) 
OpCodeData)->Length);
         FreePool(FormSetBuffer);
+        FormSetBuffer = NULL;
+        if (TempBuffer == NULL) {
+          Status = EFI_OUT_OF_RESOURCES;
+          goto Done;
+        }
+        CopyMem (TempBuffer + TempSize,  OpCodeData, ((EFI_IFR_OP_HEADER *) 
OpCodeData)->Length);
       } else {
         TempBuffer = AllocateCopyPool (TempSize + ((EFI_IFR_OP_HEADER *) 
OpCodeData)->Length, OpCodeData);
+        if (TempBuffer == NULL) {
+          Status = EFI_OUT_OF_RESOURCES;
+          goto Done;
+        }
       }
       TempSize += ((EFI_IFR_OP_HEADER *) OpCodeData)->Length;
       FormSetBuffer = TempBuffer;
 
       Status = EFI_SUCCESS;
@@ -478,10 +487,11 @@ HiiGetFormSetFromHiiHandle(
       //One form package has one formset, exit current form package to search 
other form package in the packagelist.
       //
       break;
     }
   }
+Done:
   FreePool (HiiPackageList);
 
   *BufferSize = TempSize;
   *Buffer = (EFI_IFR_FORM_SET *)FormSetBuffer;
 
-- 
1.9.5.msysgit.1

_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to