Explorar o código

* don't recurse findfirst/next if filename = . or ..
closes #40722

marcoonthegit hai 1 ano
pai
achega
56eb1e03ee
Modificáronse 1 ficheiros con 2 adicións e 1 borrados
  1. 2 1
      packages/vcl-compat/src/system.ioutils.pp

+ 2 - 1
packages/vcl-compat/src/system.ioutils.pp

@@ -2155,7 +2155,8 @@ begin
   Result      :=[];
   if (FindFirst(IntPath + aSearchPattern, TFile.FileAttributesToInteger(SearchAttributes), SearchRec) = 0) then
     repeat
-      if (aSearchOption = TSearchOption.soAllDirectories) and ((SearchRec.Attr and {$IFDEF FPC_DOTTEDUNITS}System.{$ENDIF}SysUtils.faDirectory) <> 0) then
+      if (aSearchOption = TSearchOption.soAllDirectories) and ((SearchRec.Attr and {$IFDEF FPC_DOTTEDUNITS}System.{$ENDIF}SysUtils.faDirectory) <> 0)
+         and (SearchRec.Name <> '.') and (SearchRec.Name <> '..') then
         Result:=Result + GetFilesAndDirectories(IntPath + SearchRec.Name, aSearchPattern, aSearchOption, SearchAttributes, aPredicate)
       else if FilterPredicate(aPath, SearchRec) then
         Result:=Result + [IntPath + SearchRec.Name];