summaryrefslogtreecommitdiffstats
path: root/ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c
diff options
context:
space:
mode:
authorjcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524>2012-02-02 16:55:30 +0000
committerjcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524>2012-02-02 16:55:30 +0000
commit74fa83fda6be6277044619276d0f1391e72e54a2 (patch)
tree2201a6eb748778eb6417d52772f4499199c01361 /ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c
parent66c44008ba58f74dd88a2c137449d4335c784d40 (diff)
downloadedk2-74fa83fda6be6277044619276d0f1391e72e54a2.tar.gz
edk2-74fa83fda6be6277044619276d0f1391e72e54a2.tar.bz2
edk2-74fa83fda6be6277044619276d0f1391e72e54a2.zip
ShellPkg: fix 'ls' handling of empty drives where there is not even an "." or ".." directory.
Signed-off-by: jcarsey Reviewed-by: winddy_zhang@byosoft.com.cn git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12981 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c')
-rw-r--r--ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c b/ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c
index 3799341425..55267a467a 100644
--- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c
+++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c
@@ -66,14 +66,22 @@ PrintLsOutput(
CorrectedPath = NULL;
CorrectedPath = StrnCatGrow(&CorrectedPath, NULL, Path, 0);
- ASSERT(CorrectedPath != NULL);
+ if (CorrectedPath == NULL) {
+ return (SHELL_OUT_OF_RESOURCES);
+ }
+
PathCleanUpDirectories(CorrectedPath);
Status = ShellOpenFileMetaArg((CHAR16*)CorrectedPath, EFI_FILE_MODE_READ, &ListHead);
if (EFI_ERROR(Status)) {
+ SHELL_FREE_NON_NULL(CorrectedPath);
+ if(Status == EFI_NOT_FOUND){
+ return (SHELL_NOT_FOUND);
+ }
return (SHELL_DEVICE_ERROR);
}
if (ListHead == NULL || IsListEmpty(&ListHead->Link)) {
+ SHELL_FREE_NON_NULL(CorrectedPath);
//
// On the first one only we expect to find something...
// do we find the . and .. directories otherwise?