ShellPkg/Mv: Handle memory allocation failure

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
This commit is contained in:
Ruiyu Ni 2016-07-13 17:38:51 +08:00
parent 0b34dc1324
commit 28d447f9bd
1 changed files with 9 additions and 5 deletions

View File

@ -736,11 +736,15 @@ ShellCommandRunMv (
//
CwdSize = StrSize(ShellGetCurrentDir(NULL)) + sizeof(CHAR16);
Cwd = AllocateZeroPool(CwdSize);
ASSERT (Cwd != NULL);
StrCpyS(Cwd, CwdSize/sizeof(CHAR16), ShellGetCurrentDir(NULL));
StrCatS(Cwd, CwdSize/sizeof(CHAR16), L"\\");
ShellStatus = ValidateAndMoveFiles(FileList, &Response, Cwd);
FreePool(Cwd);
if (Cwd == NULL) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_OUT_MEM), gShellLevel2HiiHandle, L"mv");
ShellStatus = SHELL_OUT_OF_RESOURCES;
} else {
StrCpyS (Cwd, CwdSize / sizeof (CHAR16), ShellGetCurrentDir (NULL));
StrCatS (Cwd, CwdSize / sizeof (CHAR16), L"\\");
ShellStatus = ValidateAndMoveFiles (FileList, &Response, Cwd);
FreePool (Cwd);
}
}
}