From 90bfa227eeb5737e3750d57b066348b381de2a70 Mon Sep 17 00:00:00 2001 From: xdu2 Date: Mon, 19 Jul 2010 05:21:27 +0000 Subject: Add some error checking. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10661 6f19259b-4bc3-4df7-8a09-765794883524 --- ShellPkg/Include/Library/ShellLib.h | 1 + ShellPkg/Library/UefiShellLib/UefiShellLib.c | 14 ++++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) (limited to 'ShellPkg') 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: -- cgit v1.2.3