summaryrefslogtreecommitdiffstats
path: root/ShellPkg/Library
diff options
context:
space:
mode:
authorRuiyu Ni <ruiyu.ni@intel.com>2016-07-13 17:38:51 +0800
committerRuiyu Ni <ruiyu.ni@intel.com>2016-07-18 11:04:07 +0800
commit28d447f9bdbc79317be60064521f81e04d72c063 (patch)
tree2f4c540b88e02fa749b3649eb03a971e3de19684 /ShellPkg/Library
parent0b34dc1324e07d330efea50222bf399a860bdbd9 (diff)
downloadedk2-28d447f9bdbc79317be60064521f81e04d72c063.tar.gz
edk2-28d447f9bdbc79317be60064521f81e04d72c063.tar.bz2
edk2-28d447f9bdbc79317be60064521f81e04d72c063.zip
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>
Diffstat (limited to 'ShellPkg/Library')
-rw-r--r--ShellPkg/Library/UefiShellLevel2CommandsLib/Mv.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Mv.c b/ShellPkg/Library/UefiShellLevel2CommandsLib/Mv.c
index d02a6ae5f5..f93772c6f8 100644
--- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Mv.c
+++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/Mv.c
@@ -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);
+ }
}
}