]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c
ShellPkg: fix 'ls' handling of empty drives where there is not even an "." or "....
[mirror_edk2.git] / ShellPkg / Library / UefiShellLevel2CommandsLib / Ls.c
index 3799341425addbe8ca8309c3bcfe6b4f227cbb6c..55267a467a02ee42cca9398c228d83d26e7d9c1d 100644 (file)
@@ -66,14 +66,22 @@ PrintLsOutput(
   CorrectedPath = NULL;\r
 \r
   CorrectedPath = StrnCatGrow(&CorrectedPath, NULL, Path, 0);\r
-  ASSERT(CorrectedPath != NULL);\r
+  if (CorrectedPath == NULL) {\r
+    return (SHELL_OUT_OF_RESOURCES);\r
+  }\r
+\r
   PathCleanUpDirectories(CorrectedPath);\r
 \r
   Status = ShellOpenFileMetaArg((CHAR16*)CorrectedPath, EFI_FILE_MODE_READ, &ListHead);\r
   if (EFI_ERROR(Status)) {\r
+    SHELL_FREE_NON_NULL(CorrectedPath);\r
+    if(Status == EFI_NOT_FOUND){\r
+      return (SHELL_NOT_FOUND);\r
+    }\r
     return (SHELL_DEVICE_ERROR);\r
   }\r
   if (ListHead == NULL || IsListEmpty(&ListHead->Link)) {\r
+    SHELL_FREE_NON_NULL(CorrectedPath);\r
     //\r
     // On the first one only we expect to find something...\r
     // do we find the . and .. directories otherwise?\r