]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c
Add code to check whether the pointer 'CorrectedPath' and 'FullPath' are NULL before...
[mirror_edk2.git] / ShellPkg / Library / UefiShellLevel2CommandsLib / Ls.c
index b5ef6aa2a9fbce870ad8a24ade61bf7121f50a14..63af5eab18884d216110df720440073607260719 100644 (file)
@@ -379,6 +379,9 @@ PrintLsOutput(
   }\r
 \r
   CorrectedPath = StrnCatGrow(&CorrectedPath, &LongestPath, RootPath,     0);\r
+  if (CorrectedPath == NULL) {\r
+    return SHELL_OUT_OF_RESOURCES;\r
+  }\r
   if (CorrectedPath[StrLen(CorrectedPath)-1] != L'\\'\r
     &&CorrectedPath[StrLen(CorrectedPath)-1] != L'/') {\r
     CorrectedPath = StrnCatGrow(&CorrectedPath, &LongestPath, L"\\",     0);\r
@@ -666,8 +669,17 @@ ShellCommandRunLs (
             ASSERT((FullPath == NULL && Size == 0) || (FullPath != NULL));\r
             if (StrStr(PathName, L":") == NULL) {\r
               StrnCatGrow(&FullPath, &Size, gEfiShellProtocol->GetCurDir(NULL), 0);\r
+              if (FullPath == NULL) {\r
+                ShellCommandLineFreeVarList (Package);\r
+                return SHELL_OUT_OF_RESOURCES;\r
+              }\r
             }\r
             StrnCatGrow(&FullPath, &Size, PathName, 0);\r
+            if (FullPath == NULL) {\r
+                ShellCommandLineFreeVarList (Package);\r
+                return SHELL_OUT_OF_RESOURCES;\r
+            }\r
+               \r
             if  (ShellIsDirectory(PathName) == EFI_SUCCESS) {\r
               //\r
               // is listing ends with a directory, then we list all files in that directory\r