Browse Source

* Fix possible infinite loop in TDirectory.IsEmpty. Fixes issue #41255

Michaël Van Canneyt 2 months ago
parent
commit
fa7636ab66
1 changed files with 2 additions and 2 deletions
  1. 2 2
      packages/vcl-compat/src/system.ioutils.pp

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

@@ -2656,10 +2656,10 @@ var
   sr: TSearchRec;
   sr: TSearchRec;
 begin
 begin
   Result:=True;
   Result:=True;
-  if (FindFirst(aPath, faAnyFile, sr) = 0) then
+  if (FindFirst(aPath + AllFilesMask, faAnyFile, sr) = 0) then
     repeat
     repeat
       Result:=(sr.Name = '.') or (sr.Name = '..');
       Result:=(sr.Name = '.') or (sr.Name = '..');
-    until Result and (FindNext(sr) = 0);
+    until not Result or (FindNext(sr) <> 0);
   {$IFDEF FPC_DOTTEDUNITS}System.{$ENDIF}SysUtils.FindClose(sr);
   {$IFDEF FPC_DOTTEDUNITS}System.{$ENDIF}SysUtils.FindClose(sr);
 end;
 end;