]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c
ShellPkg/Ls: Handle the case when SearchString is NULL
[mirror_edk2.git] / ShellPkg / Library / UefiShellLevel2CommandsLib / Ls.c
index 0b8019516f83a53abf44e00d1f483735274fea14..9b4c452ca3540b1d4f79adc4856630d09ffb15d1 100644 (file)
@@ -709,6 +709,11 @@ ShellCommandRunLs (
               // must split off the search part that applies to files from the end of the directory part\r
               //\r
               StrnCatGrow(&SearchString, NULL, FullPath, 0);\r
+              if (SearchString == NULL) {\r
+                FreePool (FullPath);\r
+                ShellCommandLineFreeVarList (Package);\r
+                return SHELL_OUT_OF_RESOURCES;\r
+              }\r
               PathRemoveLastItem (FullPath);\r
               CopyMem (SearchString, SearchString + StrLen (FullPath), StrSize (SearchString + StrLen (FullPath)));\r
             }\r