diff options
author | Ruiyu Ni <ruiyu.ni@intel.com> | 2016-07-13 17:38:51 +0800 |
---|---|---|
committer | Ruiyu Ni <ruiyu.ni@intel.com> | 2016-07-18 11:04:07 +0800 |
commit | 28d447f9bdbc79317be60064521f81e04d72c063 (patch) | |
tree | 2f4c540b88e02fa749b3649eb03a971e3de19684 /ShellPkg/Library | |
parent | 0b34dc1324e07d330efea50222bf399a860bdbd9 (diff) | |
download | edk2-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.c | 14 |
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);
+ }
}
}
|