mirror of https://github.com/acidanthera/audk.git
ShellPkg: Fixed Memory leak in UefiMain()
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Brendan Jackman <Brendan.Jackman@arm.com> Reviewed-by: Olivier Martin <olivier.martin@arm.com> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15221 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
23385d6319
commit
0477054bc0
|
@ -328,7 +328,8 @@ UefiMain (
|
||||||
///@todo Add our package into Framework HII
|
///@todo Add our package into Framework HII
|
||||||
}
|
}
|
||||||
if (ShellInfoObject.HiiHandle == NULL) {
|
if (ShellInfoObject.HiiHandle == NULL) {
|
||||||
return (EFI_NOT_STARTED);
|
Status = EFI_NOT_STARTED;
|
||||||
|
goto FreeResources;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -528,6 +529,7 @@ UefiMain (
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FreeResources:
|
||||||
//
|
//
|
||||||
// uninstall protocols / free memory / etc...
|
// uninstall protocols / free memory / etc...
|
||||||
//
|
//
|
||||||
|
@ -589,29 +591,33 @@ UefiMain (
|
||||||
DEBUG_CODE(ShellInfoObject.ConsoleInfo = NULL;);
|
DEBUG_CODE(ShellInfoObject.ConsoleInfo = NULL;);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the command exited with an error, we pass this error out in the ExitData
|
if (!EFI_ERROR (Status)) {
|
||||||
// so that it can be retrieved by the EfiShellExecute function (which may
|
// If the command exited with an error, we pass this error out in the ExitData
|
||||||
// start the shell with gBS->StartImage)
|
// so that it can be retrieved by the EfiShellExecute function (which may
|
||||||
if (ExitStatus != SHELL_SUCCESS) {
|
// start the shell with gBS->StartImage)
|
||||||
// Allocate a buffer for exit data to pass to gBS->Exit().
|
if (ExitStatus != SHELL_SUCCESS) {
|
||||||
// This buffer will contain the empty string immediately followed by
|
// Allocate a buffer for exit data to pass to gBS->Exit().
|
||||||
// the shell's exit status. (The empty string is required by the UEFI spec)
|
// This buffer will contain the empty string immediately followed by
|
||||||
ExitDataSize = (sizeof (CHAR16) + sizeof (SHELL_STATUS));
|
// the shell's exit status. (The empty string is required by the UEFI spec)
|
||||||
ExitData = AllocatePool (ExitDataSize);
|
ExitDataSize = (sizeof (CHAR16) + sizeof (SHELL_STATUS));
|
||||||
if (ExitData == NULL) {
|
ExitData = AllocatePool (ExitDataSize);
|
||||||
return EFI_OUT_OF_RESOURCES;
|
if (ExitData == NULL) {
|
||||||
|
return EFI_OUT_OF_RESOURCES;
|
||||||
|
}
|
||||||
|
ExitData[0] = '\0';
|
||||||
|
// Use CopyMem to avoid alignment faults
|
||||||
|
CopyMem ((ExitData + 1), &ExitStatus, sizeof (ExitStatus));
|
||||||
|
|
||||||
|
gBS->Exit (ImageHandle, EFI_ABORTED, ExitDataSize, ExitData);
|
||||||
|
|
||||||
|
ASSERT (FALSE);
|
||||||
|
return EFI_SUCCESS;
|
||||||
|
} else {
|
||||||
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
ExitData[0] = '\0';
|
|
||||||
// Use CopyMem to avoid alignment faults
|
|
||||||
CopyMem ((ExitData + 1), &ExitStatus, sizeof (ExitStatus));
|
|
||||||
|
|
||||||
gBS->Exit (ImageHandle, EFI_ABORTED, ExitDataSize, ExitData);
|
|
||||||
} else {
|
} else {
|
||||||
return EFI_SUCCESS;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSERT (FALSE);
|
|
||||||
return EFI_SUCCESS;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue