MdePkg/BasePeCoffLib2: Fix uninitialized RtContext for RelocateImage()

This commit is contained in:
Marvin Häuser 2023-04-27 17:32:35 +02:00 committed by Mikhail Krichanov
parent 3a16df0e2d
commit 6d772a4b8e

View File

@ -438,6 +438,13 @@ PeCoffRelocateImage (
ASSERT (RuntimeContext != NULL || RuntimeContextSize == 0);
ASSERT (RuntimeContext == NULL || RuntimeContextSize >= sizeof (PE_COFF_LOADER_RUNTIME_CONTEXT) + Context->RelocDirSize * (sizeof (UINT64) / sizeof (UINT16)));
//
// Initialise the Image runtime context header.
//
if (RuntimeContext != NULL) {
RuntimeContext->RelocDirRva = Context->RelocDirRva;
RuntimeContext->RelocDirSize = Context->RelocDirSize;
}
//
// Verify the Relocation Directory is not empty.
//
if (Context->RelocDirSize == 0) {
@ -458,13 +465,6 @@ PeCoffRelocateImage (
if (RuntimeContext == NULL && Adjust == 0) {
return RETURN_SUCCESS;
}
//
// Initialise the Image runtime context header.
//
if (RuntimeContext != NULL) {
RuntimeContext->RelocDirRva = Context->RelocDirRva;
RuntimeContext->RelocDirSize = Context->RelocDirSize;
}
RelocBlockOffset = Context->RelocDirRva;
TopOfRelocDir = Context->RelocDirRva + Context->RelocDirSize;