Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
UINT32 ScratchSize;\r
EFI_STATUS Status;\r
\r
UINT32 ScratchSize;\r
EFI_STATUS Status;\r
\r
- Status = EFI_SUCCESS;\r
+ Scratch = NULL;\r
+ Status = EFI_SUCCESS;\r
+\r
switch (Algorithm) {\r
case 0:\r
*Destination = (VOID *)malloc(SrcSize);\r
switch (Algorithm) {\r
case 0:\r
*Destination = (VOID *)malloc(SrcSize);\r
Status = EfiGetInfo(Source, SrcSize, DstSize, &ScratchSize);\r
if (Status == EFI_SUCCESS) {\r
Scratch = (VOID *)malloc(ScratchSize);\r
Status = EfiGetInfo(Source, SrcSize, DstSize, &ScratchSize);\r
if (Status == EFI_SUCCESS) {\r
Scratch = (VOID *)malloc(ScratchSize);\r
+ if (Scratch == NULL) {\r
+ return EFI_OUT_OF_RESOURCES;\r
+ }\r
+\r
*Destination = (VOID *)malloc(*DstSize);\r
*Destination = (VOID *)malloc(*DstSize);\r
- if (Scratch != NULL && *Destination != NULL) {\r
- Status = EfiDecompress(Source, SrcSize, *Destination, *DstSize, Scratch, ScratchSize);\r
- } else {\r
- Status = EFI_OUT_OF_RESOURCES;\r
+ if (*Destination == NULL) {\r
+ free (Scratch);\r
+ return EFI_OUT_OF_RESOURCES;\r
+\r
+ Status = EfiDecompress(Source, SrcSize, *Destination, *DstSize, Scratch, ScratchSize);\r
}\r
break;\r
case 2:\r
Status = TianoGetInfo(Source, SrcSize, DstSize, &ScratchSize);\r
if (Status == EFI_SUCCESS) {\r
Scratch = (VOID *)malloc(ScratchSize);\r
}\r
break;\r
case 2:\r
Status = TianoGetInfo(Source, SrcSize, DstSize, &ScratchSize);\r
if (Status == EFI_SUCCESS) {\r
Scratch = (VOID *)malloc(ScratchSize);\r
+ if (Scratch == NULL) {\r
+ return EFI_OUT_OF_RESOURCES;\r
+ }\r
+\r
*Destination = (VOID *)malloc(*DstSize);\r
*Destination = (VOID *)malloc(*DstSize);\r
- if (Scratch != NULL && *Destination != NULL) {\r
- Status = TianoDecompress(Source, SrcSize, *Destination, *DstSize, Scratch, ScratchSize);\r
- } else {\r
- Status = EFI_OUT_OF_RESOURCES;\r
+ if (*Destination == NULL) {\r
+ free (Scratch);\r
+ return EFI_OUT_OF_RESOURCES;\r
+\r
+ Status = TianoDecompress(Source, SrcSize, *Destination, *DstSize, Scratch, ScratchSize);\r
}\r
break;\r
default:\r
Status = EFI_INVALID_PARAMETER;\r
}\r
\r
}\r
break;\r
default:\r
Status = EFI_INVALID_PARAMETER;\r
}\r
\r
+ if (Scratch != NULL) {\r
+ free (Scratch);\r
+ }\r
+\r
\r
Status = FvBufClearAllFiles (TempFv);\r
if (EFI_ERROR (Status)) {\r
\r
Status = FvBufClearAllFiles (TempFv);\r
if (EFI_ERROR (Status)) {\r
+ CommonLibBinderFree (TempFv);\r
/** @file\r
This contains some useful functions for accessing files.\r
\r
/** @file\r
This contains some useful functions for accessing files.\r
\r
-Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 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
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
\r
NewMemoryFile = malloc (sizeof (*NewMemoryFile));\r
if (NewMemoryFile == NULL) {\r
\r
NewMemoryFile = malloc (sizeof (*NewMemoryFile));\r
if (NewMemoryFile == NULL) {\r
+ free (InputFileImage);\r
return EFI_OUT_OF_RESOURCES;\r
}\r
\r
return EFI_OUT_OF_RESOURCES;\r
}\r
\r
\r
Status = StripInfDscStringInPlace (NextLine);\r
if (EFI_ERROR (Status)) {\r
\r
Status = StripInfDscStringInPlace (NextLine);\r
if (EFI_ERROR (Status)) {\r
break;\r
}\r
\r
if (NextLine[0] == '\0') {\r
break;\r
}\r
\r
if (NextLine[0] == '\0') {\r
LastGuidTool = NewGuidTool;\r
}\r
}\r
LastGuidTool = NewGuidTool;\r
}\r
}\r
+ }\r
+\r
+ if (Tool != NULL) {\r
FreeStringList (Tool);\r
}\r
FreeStringList (Tool);\r
}\r
}\r
\r
return FirstGuidTool;\r
}\r
\r
return FirstGuidTool;\r