diff --git a/components/codetools/fileprocs.pas b/components/codetools/fileprocs.pas index 0b8ab3d804..fac73a0f04 100644 --- a/components/codetools/fileprocs.pas +++ b/components/codetools/fileprocs.pas @@ -1141,8 +1141,8 @@ begin try // read the first 1024 bytes Len:=1024; - SetLength(Buf,1024+1); - Len:=fs.Read(Buf[1],length(Buf)); + SetLength(Buf,Len+1); + Len:=fs.Read(Buf[1],Len); if Len>0 then begin Buf[Len+1]:=#0; p:=PChar(Buf);