Verify memory allocations were successful.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10909 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
jcarsey
2010-10-04 16:30:40 +00:00
parent d38a107995
commit 9ea69f8a05
7 changed files with 165 additions and 111 deletions

View File

@ -186,17 +186,27 @@ ShellCommandRunCd (
// change directory on other drive letter
//
Drive = AllocateZeroPool(StrSize(Param1));
Drive = StrCpy(Drive, Param1);
Path = StrStr(Drive, L":");
*(++Path) = CHAR_NULL;
Status = gEfiShellProtocol->SetCurDir(Drive, ++Path);
if (Drive == NULL) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_MEM), gShellLevel2HiiHandle);
ShellStatus = SHELL_OUT_OF_RESOURCES;
} else {
Drive = StrCpy(Drive, Param1);
Path = StrStr(Drive, L":");
*(++Path) = CHAR_NULL;
if (Path == Drive + StrLen(Drive)) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_CD_NF), gShellLevel2HiiHandle);
ShellStatus = SHELL_NOT_FOUND;
} else {
Status = gEfiShellProtocol->SetCurDir(Drive, ++Path);
}
if (Status == EFI_NOT_FOUND) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_CD_NF), gShellLevel2HiiHandle);
Status = SHELL_NOT_FOUND;
} else if (EFI_ERROR(Status)) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_DIR_NF), gShellLevel2HiiHandle, Param1);
Status = SHELL_NOT_FOUND;
if (Status == EFI_NOT_FOUND) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_CD_NF), gShellLevel2HiiHandle);
Status = SHELL_NOT_FOUND;
} else if (EFI_ERROR(Status)) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_DIR_NF), gShellLevel2HiiHandle, Param1);
Status = SHELL_NOT_FOUND;
}
}
}
}