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:
Brendan Jackman 2014-02-11 22:42:49 +00:00 committed by jcarsey
parent 23385d6319
commit 0477054bc0
1 changed files with 27 additions and 21 deletions

View File

@ -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,6 +591,7 @@ UefiMain (
DEBUG_CODE(ShellInfoObject.ConsoleInfo = NULL;); DEBUG_CODE(ShellInfoObject.ConsoleInfo = NULL;);
} }
if (!EFI_ERROR (Status)) {
// If the command exited with an error, we pass this error out in the ExitData // If the command exited with an error, we pass this error out in the ExitData
// so that it can be retrieved by the EfiShellExecute function (which may // so that it can be retrieved by the EfiShellExecute function (which may
// start the shell with gBS->StartImage) // start the shell with gBS->StartImage)
@ -606,12 +609,15 @@ UefiMain (
CopyMem ((ExitData + 1), &ExitStatus, sizeof (ExitStatus)); CopyMem ((ExitData + 1), &ExitStatus, sizeof (ExitStatus));
gBS->Exit (ImageHandle, EFI_ABORTED, ExitDataSize, ExitData); gBS->Exit (ImageHandle, EFI_ABORTED, ExitDataSize, ExitData);
} else {
return EFI_SUCCESS;
}
ASSERT (FALSE); ASSERT (FALSE);
return EFI_SUCCESS; return EFI_SUCCESS;
} else {
return EFI_SUCCESS;
}
} else {
return Status;
}
} }
/** /**