From: Ruiyu Ni Date: Tue, 16 Aug 2016 07:32:18 +0000 (+0800) Subject: ShellPkg/Ls: Handle the case when SearchString is NULL X-Git-Tag: edk2-stable201903~6034 X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=commitdiff_plain;h=795c78cf190ba7ac3e7edd76e6c31b8505c2d739 ShellPkg/Ls: Handle the case when SearchString is NULL Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ruiyu Ni Reviewed-by: Hao Wu --- diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c b/ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c index 0b8019516f..9b4c452ca3 100644 --- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c +++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c @@ -709,6 +709,11 @@ ShellCommandRunLs ( // must split off the search part that applies to files from the end of the directory part // StrnCatGrow(&SearchString, NULL, FullPath, 0); + if (SearchString == NULL) { + FreePool (FullPath); + ShellCommandLineFreeVarList (Package); + return SHELL_OUT_OF_RESOURCES; + } PathRemoveLastItem (FullPath); CopyMem (SearchString, SearchString + StrLen (FullPath), StrSize (SearchString + StrLen (FullPath))); }