ShellPkg/Ls: Handle the case when SearchString is NULL

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Hao Wu <hao.a.wu@intel.com>
This commit is contained in:
Ruiyu Ni 2016-08-16 15:32:18 +08:00
parent fd4d9c6495
commit 795c78cf19
1 changed files with 5 additions and 0 deletions

View File

@ -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)));
}