diff options
author | xdu2 <xdu2@6f19259b-4bc3-4df7-8a09-765794883524> | 2010-07-19 05:21:27 +0000 |
---|---|---|
committer | xdu2 <xdu2@6f19259b-4bc3-4df7-8a09-765794883524> | 2010-07-19 05:21:27 +0000 |
commit | 90bfa227eeb5737e3750d57b066348b381de2a70 (patch) | |
tree | 17dd8baab416ea4ba2dc1736723472ddf61a714b /ShellPkg | |
parent | 4cf7e0380ebf7e07c2ddee3d2c20daaeb66203a3 (diff) | |
download | edk2-platforms-90bfa227eeb5737e3750d57b066348b381de2a70.tar.xz |
Add some error checking.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10661 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'ShellPkg')
-rw-r--r-- | ShellPkg/Include/Library/ShellLib.h | 1 | ||||
-rw-r--r-- | ShellPkg/Library/UefiShellLib/UefiShellLib.c | 14 |
2 files changed, 11 insertions, 4 deletions
diff --git a/ShellPkg/Include/Library/ShellLib.h b/ShellPkg/Include/Library/ShellLib.h index bc9a6cfd23..b697922200 100644 --- a/ShellPkg/Include/Library/ShellLib.h +++ b/ShellPkg/Include/Library/ShellLib.h @@ -1134,6 +1134,7 @@ typedef enum { @retval EFI_SUCCESS The operation was sucessful.
@retval EFI_UNSUPPORTED The operation is not supported as requested.
@retval EFI_INVALID_PARAMETER A parameter was invalid.
+ @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
@return other The operation failed.
**/
EFI_STATUS
diff --git a/ShellPkg/Library/UefiShellLib/UefiShellLib.c b/ShellPkg/Library/UefiShellLib/UefiShellLib.c index fcb7e430ed..d3cc59e9be 100644 --- a/ShellPkg/Library/UefiShellLib/UefiShellLib.c +++ b/ShellPkg/Library/UefiShellLib/UefiShellLib.c @@ -623,7 +623,7 @@ ShellOpenFileByName( //
ASSERT(mEfiShellEnvironment2 != NULL);
FilePath = mEfiShellEnvironment2->NameToPath ((CHAR16*)FileName);
- if (FileDevicePath != NULL) {
+ if (FilePath != NULL) {
return (ShellOpenFileByDevicePath(&FilePath,
&DeviceHandle,
FileHandle,
@@ -1522,6 +1522,10 @@ ShellFindFilePath ( Size = StrSize(Path);
Size += StrSize(FileName);
TestPath = AllocateZeroPool(Size);
+ ASSERT(TestPath != NULL);
+ if (TestPath == NULL) {
+ return (NULL);
+ }
Walker = (CHAR16*)Path;
do {
CopyMem(TestPath, Walker, StrSize(Walker));
@@ -1594,9 +1598,7 @@ ShellFindFilePathEx ( }
for (ExtensionWalker = FileExtension, TempChar2 = (CHAR16*)FileExtension; TempChar2 != NULL ; ExtensionWalker = TempChar2 + 1 ){
StrCpy(TestPath, FileName);
- if (ExtensionWalker != NULL) {
- StrCat(TestPath, ExtensionWalker);
- }
+ StrCat(TestPath, ExtensionWalker);
TempChar = StrStr(TestPath, L";");
if (TempChar != NULL) {
*TempChar = CHAR_NULL;
@@ -2850,6 +2852,7 @@ StrnCatGrow ( @retval EFI_SUCCESS The operation was sucessful.
@retval EFI_UNSUPPORTED The operation is not supported as requested.
@retval EFI_INVALID_PARAMETER A parameter was invalid.
+ @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
@return other The operation failed.
**/
EFI_STATUS
@@ -2867,6 +2870,9 @@ ShellPromptForResponse ( Status = EFI_SUCCESS;
Resp = (SHELL_PROMPT_RESPONSE*)AllocatePool(sizeof(SHELL_PROMPT_RESPONSE));
+ if (Resp == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
switch(Type) {
case SHELL_PROMPT_REQUEST_TYPE_QUIT_CONTINUE:
|