OpenCore: Avoid dangling booter protocol on load failure

This commit is contained in:
vit9696 2019-04-09 13:45:40 +03:00
parent 7bbf38a498
commit fd47a4db0c
3 changed files with 14 additions and 13 deletions

View File

@ -55,3 +55,4 @@
MemoryAllocationLib
OcDevicePathLib
OcFileLib
OcStringLib

View File

@ -203,18 +203,6 @@ UefiMain (
return EFI_ALREADY_STARTED;
}
BootstrapHandle = NULL;
Status = gBS->InstallMultipleProtocolInterfaces (
&BootstrapHandle,
&gOcBootstrapProtocolGuid,
&mOpenCoreBootStrap,
NULL
);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "OC: Failed to install bootstrap protocol - %r\n", Status));
return Status;
}
LoadedImage = NULL;
Status = gBS->HandleProtocol (
ImageHandle,
@ -227,6 +215,18 @@ UefiMain (
return EFI_NOT_FOUND;
}
BootstrapHandle = NULL;
Status = gBS->InstallMultipleProtocolInterfaces (
&BootstrapHandle,
&gOcBootstrapProtocolGuid,
&mOpenCoreBootStrap,
NULL
);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "OC: Failed to install bootstrap protocol - %r\n", Status));
return Status;
}
DebugPrintDevicePath (DEBUG_INFO, "OC: Booter path", LoadedImage->FilePath);
if (LoadedImage->FilePath == NULL) {

View File

@ -59,7 +59,7 @@ OcKernelReadDarwinVersion (
Offset += L_STR_LEN ("Darwin Kernel Version ");
for (Index = 0; Index < DarwinVersionSize - 1; ++Index, ++Offset) {
if (Offset >= KernelSize || Kernel[Offset] == ':') {
if ((UINT32) Offset >= KernelSize || Kernel[Offset] == ':') {
break;
}
DarwinVersion[Index] = (CHAR8) Kernel[Offset];