]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/C/Common/FirmwareVolumeBuffer.c
BaseTools: Fix the bug for QuarkPlatformPkg build failure
[mirror_edk2.git] / BaseTools / Source / C / Common / FirmwareVolumeBuffer.c
index fa6ca6bd6d192581bbcd603ec5e5f02272994ddf..d4a635335a6e3ffbb47012d577f85d9216a1995a 100644 (file)
@@ -1,6 +1,7 @@
 /** @file\r
+EFI Firmware Volume routines which work on a Fv image in buffers.\r
 \r
-Copyright (c) 1999 - 2014, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 1999 - 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
@@ -9,14 +10,6 @@ http://opensource.org/licenses/bsd-license.php
 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
 \r
-Module Name:\r
-\r
-  FirmwareVolumeBuffer.c\r
-\r
-Abstract:\r
-\r
-  EFI Firmware Volume routines which work on a Fv image in buffers.\r
-\r
 **/\r
 \r
 #include "FirmwareVolumeBufferLib.h"\r
@@ -32,6 +25,11 @@ Abstract:
         ) \\r
     )\r
 \r
+\r
+//\r
+// Local prototypes\r
+//\r
+\r
 STATIC\r
 UINT32\r
 FvBufGetSecHdrLen(\r
@@ -188,6 +186,7 @@ Returns:
 \r
   Status = FvBufClearAllFiles (TempFv);\r
   if (EFI_ERROR (Status)) {\r
+    CommonLibBinderFree (TempFv);\r
     return Status;\r
   }\r
 \r
@@ -355,6 +354,9 @@ Returns:
 \r
   if (*DestinationFv == NULL) {\r
     *DestinationFv = CommonLibBinderAllocate (size);\r
+    if (*DestinationFv == NULL) {\r
+      return EFI_OUT_OF_RESOURCES;\r
+    }\r
   }\r
 \r
   CommonLibBinderCopyMem (*DestinationFv, SourceFv, size);\r
@@ -866,7 +868,7 @@ Returns:
     return 0;\r
   }\r
   if (Ffs->Attributes & FFS_ATTRIB_LARGE_FILE) {\r
-    return ((EFI_FFS_FILE_HEADER2 *)Ffs)->ExtendedSize;\r
+    return (UINT32) ((EFI_FFS_FILE_HEADER2 *)Ffs)->ExtendedSize;\r
   }\r
   return FvBufExpand3ByteSize(Ffs->Size);\r
 }\r