summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--MdeModulePkg/Core/Dxe/Image/Image.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/MdeModulePkg/Core/Dxe/Image/Image.c b/MdeModulePkg/Core/Dxe/Image/Image.c
index 08306a73fd..de5b8bed27 100644
--- a/MdeModulePkg/Core/Dxe/Image/Image.c
+++ b/MdeModulePkg/Core/Dxe/Image/Image.c
@@ -134,12 +134,14 @@ PeCoffEmuProtocolNotify (
IN VOID *Context
)
{
- EFI_STATUS Status;
- UINTN BufferSize;
- EFI_HANDLE EmuHandle;
- EMULATOR_ENTRY *Entry;
+ EFI_STATUS Status;
+ UINTN BufferSize;
+ EFI_HANDLE EmuHandle;
+ EDKII_PECOFF_IMAGE_EMULATOR_PROTOCOL *Emulator;
+ EMULATOR_ENTRY *Entry;
EmuHandle = NULL;
+ Emulator = NULL;
while (TRUE) {
BufferSize = sizeof (EmuHandle);
@@ -157,16 +159,19 @@ PeCoffEmuProtocolNotify (
return;
}
- Entry = AllocateZeroPool (sizeof (*Entry));
- ASSERT (Entry != NULL);
-
Status = CoreHandleProtocol (
EmuHandle,
&gEdkiiPeCoffImageEmulatorProtocolGuid,
- (VOID **)&Entry->Emulator
+ (VOID **)&Emulator
);
- ASSERT_EFI_ERROR (Status);
+ if (EFI_ERROR (Status) || Emulator == NULL) {
+ continue;
+ }
+
+ Entry = AllocateZeroPool (sizeof (*Entry));
+ ASSERT (Entry != NULL);
+ Entry->Emulator = Emulator;
Entry->MachineType = Entry->Emulator->MachineType;
InsertTailList (&mAvailableEmulators, &Entry->Link);