From 463d803d7c8e491ba0425bf6b89280261ae74415 Mon Sep 17 00:00:00 2001 From: Ruiyu Ni Date: Wed, 13 Jul 2016 17:38:51 +0800 Subject: ShellPkg/Mv: Handle memory allocation failure Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ruiyu Ni Reviewed-by: Jaben Carsey (cherry picked from commit 28d447f9bdbc79317be60064521f81e04d72c063) --- ShellPkg/Library/UefiShellLevel2CommandsLib/Mv.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'ShellPkg') 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); + } } } -- cgit v1.2.3