diff options
author | Star Zeng <star.zeng@intel.com> | 2017-06-23 17:44:12 +0800 |
---|---|---|
committer | Star Zeng <star.zeng@intel.com> | 2017-06-26 13:17:16 +0800 |
commit | 4777032247fb3cbc8325881572aa8a83ccd9db93 (patch) | |
tree | 75864b444955b810ea7dbfd38b0f77ff56f89199 /MdeModulePkg/Core | |
parent | 45cfcd8dccf84b8abbc1d6f587fedb5d2037ec79 (diff) | |
download | edk2-4777032247fb3cbc8325881572aa8a83ccd9db93.tar.gz edk2-4777032247fb3cbc8325881572aa8a83ccd9db93.tar.bz2 edk2-4777032247fb3cbc8325881572aa8a83ccd9db93.zip |
MdeModulePkg DxeCore: Only free ScratchBuffer when it is not NULL
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>
Diffstat (limited to 'MdeModulePkg/Core')
-rw-r--r-- | MdeModulePkg/Core/Dxe/SectionExtraction/CoreSectionExtraction.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/MdeModulePkg/Core/Dxe/SectionExtraction/CoreSectionExtraction.c b/MdeModulePkg/Core/Dxe/SectionExtraction/CoreSectionExtraction.c index 6622eeeaf1..9561ae1766 100644 --- a/MdeModulePkg/Core/Dxe/SectionExtraction/CoreSectionExtraction.c +++ b/MdeModulePkg/Core/Dxe/SectionExtraction/CoreSectionExtraction.c @@ -27,7 +27,7 @@ 3) A support protocol is not found, and the data is not available to be read
without it. This results in EFI_PROTOCOL_ERROR.
-Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2017, 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
@@ -1551,7 +1551,9 @@ CustomGuidedSectionExtract ( //
AllocatedOutputBuffer = AllocatePool (OutputBufferSize);
if (AllocatedOutputBuffer == NULL) {
- FreePool (ScratchBuffer);
+ if (ScratchBuffer != NULL) {
+ FreePool (ScratchBuffer);
+ }
return EFI_OUT_OF_RESOURCES;
}
*OutputBuffer = AllocatedOutputBuffer;
|