[lazarus] Corrupted form
Michael Van Canneyt
michael.vancanneyt at wisa.be
Fri Sep 20 08:16:43 EDT 2002
On Fri, 20 Sep 2002, Mattias Gaertner wrote:
> On Thu, 19 Sep 2002 22:09:53 -0500
> "Tony Maro" <TonyM at nlisc.com> wrote:
>
> > I was just noticing that the form resource appears streamed from a buffer of 4096 bytes. (main.pp: dosavefileresources) Are we passing that threshold?
> >
> > I just recompiled Lazarus after bumping that to 8192 and haven't been able to reproduce the problem since (yet...)
>
> That's it.
> It is a bug in TBinaryObjectWriter.Write.
> Buffer is not adjusted. Here is a fixed version:
>
> procedure TBinaryObjectWriter.Write(const Buffer; Count: LongInt);
> var
> CopyNow: LongInt;
> SourceBuf: PChar;
> begin
> SourceBuf:=@Buffer;
> while Count > 0 do
> begin
> CopyNow := Count;
> if CopyNow > FBufSize - FBufPos then
> CopyNow := FBufSize - FBufPos;
> Move(SourceBuf^, PChar(FBuffer)[FBufPos], CopyNow);
> Dec(Count, CopyNow);
> Inc(FBufPos, CopyNow);
> inc(SourceBuf, CopyNow);
> if FBufPos = FBufSize then
> FlushBuffer;
> end;
> end;
>
> I hope someone of the fpc team reads this and fixes it.
Fixed.
Michael.
More information about the Lazarus
mailing list