Browse Source

* leave GetFileContents() early if the file size is 0 to avoid a range error if the RTL is compiled with range checks

Sven/Sarah Barth 6 months ago
parent
commit
9fccadc1f0
1 changed files with 2 additions and 0 deletions
  1. 2 0
      rtl/objpas/sysutils/filutil.inc

+ 2 - 0
rtl/objpas/sysutils/filutil.inc

@@ -866,6 +866,8 @@ begin
   if FileSeek(aHandle,0,fsFromBeginning)<0 then
   if FileSeek(aHandle,0,fsFromBeginning)<0 then
     Raise EInOutError.Create(SSeekFailed);
     Raise EInOutError.Create(SSeekFailed);
   SetLength(Result,aLen);
   SetLength(Result,aLen);
+  if aLen=0 then
+    Exit;
   aOffset:=0;
   aOffset:=0;
   Repeat
   Repeat
     aBuf:=@Result[aOffset];
     aBuf:=@Result[aOffset];