There is a case that ExtractGuidedSectionGetInfo return 0 for
ScratchBufferSize and ScratchBuffer will be NULL, after AllocatePool
fails to allocate buffer for AllocatedOutputBuffer, the code will
call FreePool (ScratchBuffer), but ScratchBuffer == NULL.
This patch is to only free ScratchBuffer when it is not NULL.
Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
3) A support protocol is not found, and the data is not available to be read\r
without it. This results in EFI_PROTOCOL_ERROR.\r
\r
3) A support protocol is not found, and the data is not available to be read\r
without it. This results in EFI_PROTOCOL_ERROR.\r
\r
-Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2017, 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
AllocatedOutputBuffer = AllocatePool (OutputBufferSize);\r
if (AllocatedOutputBuffer == NULL) {\r
//\r
AllocatedOutputBuffer = AllocatePool (OutputBufferSize);\r
if (AllocatedOutputBuffer == NULL) {\r
- FreePool (ScratchBuffer);\r
+ if (ScratchBuffer != NULL) {\r
+ FreePool (ScratchBuffer);\r
+ }\r
return EFI_OUT_OF_RESOURCES;\r
}\r
*OutputBuffer = AllocatedOutputBuffer;\r
return EFI_OUT_OF_RESOURCES;\r
}\r
*OutputBuffer = AllocatedOutputBuffer;\r