- Drive = StrCpy(Drive, Param1);\r
- Path = StrStr(Drive, L":");\r
- *(++Path) = CHAR_NULL;\r
- Status = gEfiShellProtocol->SetCurDir(Drive, ++Path);\r
+ if (Drive == NULL) {\r
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_MEM), gShellLevel2HiiHandle);\r
+ ShellStatus = SHELL_OUT_OF_RESOURCES;\r
+ } else {\r
+ Drive = StrCpy(Drive, Param1);\r
+ Path = StrStr(Drive, L":");\r
+ *(++Path) = CHAR_NULL;\r
+ if (Path == Drive + StrLen(Drive)) {\r
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_CD_NF), gShellLevel2HiiHandle);\r
+ ShellStatus = SHELL_NOT_FOUND;\r
+ } else {\r
+ Status = gEfiShellProtocol->SetCurDir(Drive, ++Path);\r
+ }\r