diff options
author | Ruiyu Ni <ruiyu.ni@intel.com> | 2016-07-13 17:38:51 +0800 |
---|---|---|
committer | Hao Wu <hao.a.wu@intel.com> | 2016-07-25 11:05:05 +0800 |
commit | 463d803d7c8e491ba0425bf6b89280261ae74415 (patch) | |
tree | 39c668f388b1bfff75949fd2578539eff939b92c | |
parent | 3b6c1c8739ad818cacb661ef9cfe5f91104d8009 (diff) | |
download | edk2-platforms-463d803d7c8e491ba0425bf6b89280261ae74415.tar.xz |
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>
(cherry picked from commit 28d447f9bdbc79317be60064521f81e04d72c063)
-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);
+ }
}
}
|