Add check for memory allocation.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@8678 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
xli24 2009-06-29 07:29:39 +00:00
parent d14faa5275
commit 1fa282ec23
1 changed files with 6 additions and 2 deletions

View File

@ -491,11 +491,15 @@ ReportStatusCodeEx (
ASSERT (!((ExtendedData == NULL) && (ExtendedDataSize != 0))); ASSERT (!((ExtendedData == NULL) && (ExtendedDataSize != 0)));
ASSERT (!((ExtendedData != NULL) && (ExtendedDataSize == 0))); ASSERT (!((ExtendedData != NULL) && (ExtendedDataSize == 0)));
if (gBS == NULL || gBS->AllocatePool == NULL || gBS->FreePool == NULL) {
return EFI_UNSUPPORTED;
}
// //
// Allocate space for the Status Code Header and its buffer // Allocate space for the Status Code Header and its buffer
// //
StatusCodeData = NULL; StatusCodeData = NULL;
StatusCodeData = AllocatePool (sizeof (EFI_STATUS_CODE_DATA) + ExtendedDataSize); gBS->AllocatePool (EfiBootServicesData, sizeof (EFI_STATUS_CODE_DATA) + ExtendedDataSize, (VOID **)&StatusCodeData);
if (StatusCodeData == NULL) { if (StatusCodeData == NULL) {
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
@ -528,7 +532,7 @@ ReportStatusCodeEx (
// //
// Free the allocated buffer // Free the allocated buffer
// //
FreePool (StatusCodeData); gBS->FreePool (StatusCodeData);
return Status; return Status;
} }