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
This commit is contained in:
lzeng14 2012-09-07 01:35:44 +00:00
parent 0407056e64
commit 16bacc0720
1 changed files with 7 additions and 5 deletions

View File

@ -389,7 +389,10 @@ GetPeCoffImageFixLoadingAssignedAddress(
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return Status; return Status;
} }
if (Size != sizeof (EFI_IMAGE_SECTION_HEADER)) {
return EFI_NOT_FOUND;
}
Status = EFI_NOT_FOUND; Status = EFI_NOT_FOUND;
if ((SectionHeader.Characteristics & EFI_IMAGE_SCN_CNT_CODE) == 0) { 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; Image = NULL;
goto Done; goto Done;
} else if (EFI_ERROR (Status)) {
return Status;
} }
if (gSecurity2 != NULL) { if (gSecurity2 != NULL) {
@ -1194,7 +1195,8 @@ CoreLoadImageCommon (
// //
Image = AllocateZeroPool (sizeof(LOADED_IMAGE_PRIVATE_DATA)); Image = AllocateZeroPool (sizeof(LOADED_IMAGE_PRIVATE_DATA));
if (Image == NULL) { if (Image == NULL) {
return EFI_OUT_OF_RESOURCES; Status = EFI_OUT_OF_RESOURCES;
goto Done;
} }
// //