diff options
author | lzeng14 <lzeng14@6f19259b-4bc3-4df7-8a09-765794883524> | 2012-09-07 01:35:44 +0000 |
---|---|---|
committer | lzeng14 <lzeng14@6f19259b-4bc3-4df7-8a09-765794883524> | 2012-09-07 01:35:44 +0000 |
commit | 16bacc07205af83520ddbdb9f69ac12011659b66 (patch) | |
tree | 5de889e771dd74d23bb1adf69c0eef134741ac38 | |
parent | 0407056e649dfe095e6d6e218a619a512896a9ae (diff) | |
download | edk2-platforms-16bacc07205af83520ddbdb9f69ac12011659b66.tar.xz |
Fix the memory leak issue and enhance the check for CoreReadImageFile return.
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Ting Ye <ting.ye@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13704 6f19259b-4bc3-4df7-8a09-765794883524
-rw-r--r-- | MdeModulePkg/Core/Dxe/Image/Image.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/MdeModulePkg/Core/Dxe/Image/Image.c b/MdeModulePkg/Core/Dxe/Image/Image.c index 16fc91056a..8a3e869be6 100644 --- a/MdeModulePkg/Core/Dxe/Image/Image.c +++ b/MdeModulePkg/Core/Dxe/Image/Image.c @@ -389,7 +389,10 @@ GetPeCoffImageFixLoadingAssignedAddress( if (EFI_ERROR (Status)) {
return Status;
}
-
+ if (Size != sizeof (EFI_IMAGE_SECTION_HEADER)) {
+ return EFI_NOT_FOUND;
+ }
+
Status = EFI_NOT_FOUND;
if ((SectionHeader.Characteristics & EFI_IMAGE_SCN_CNT_CODE) == 0) {
@@ -1128,11 +1131,9 @@ CoreLoadImageCommon ( }
}
- if (Status == EFI_ALREADY_STARTED) {
+ if (EFI_ERROR (Status)) {
Image = NULL;
goto Done;
- } else if (EFI_ERROR (Status)) {
- return Status;
}
if (gSecurity2 != NULL) {
@@ -1194,7 +1195,8 @@ CoreLoadImageCommon ( //
Image = AllocateZeroPool (sizeof(LOADED_IMAGE_PRIVATE_DATA));
if (Image == NULL) {
- return EFI_OUT_OF_RESOURCES;
+ Status = EFI_OUT_OF_RESOURCES;
+ goto Done;
}
//
|