Exported from Bugzilla, issue 3851.
--- Comment added on 9/16/2002 2:30:42 PM ---
Customer Reports:
Subject: Range check error with TStBufferedStream
Date: Tue, 20 Aug 2002 22:11:06 +0200
-------------------->8 cut here 8<--------------------
what's wrong with this code?
uses ... ststrms;
procedure TForm1.Button1Click(Sender: TObject);
var fs:tfilestream;
fsBuffer:TStBufferedStream;
ss:TStringStream;
s:string;
i:integer;
begin
//create a 100 KB test file
fs:=TFileStream.Create(ChangeFileExt(Application.ExeName,'.testfile'),fmcreate);
try
for i:=0 to 255 do s:=s+char(i);
for i:=1 to 400 do fs.WriteBuffer(s[1],length(s));
finally
fs.Free;
end;
//copy the contents of a buffered file stream to a string stream
fs:=Tfilestream.Create(ChangeFileExt(Application.ExeName,'.testfile'),fmOpenRead
);
fsBuffer:=TStBufferedStream.Create(fs);
ss:=TStringStream.Create('');
try
ss.CopyFrom(fsbuffer,0);
finally
ss.Free;
fsbuffer.Free;
fs.Free;
end
end;
I am getting "Range check error" on the ss.copyfrom line. (This is
independent from the "Range checking" project option).
This only seems to happens on files (streams) larger than 32 KB.
-------------------->8 cut here 8<--------------------
In reply to myself, maybe the 60KB buffer used in classes.TStream.CopyFrom
conflicts with the 4KB buffer of TStBufferedStream?
-------------------->8 cut here 8<--------------------
Logged In: YES
user_id=689612
this is not reproducable with delphi 7 and the current source
code on sourceforge (4.02).