[lazarus] Corrupted form

Mattias Gaertner nc-gaertnma at netcologne.de
Fri Sep 20 06:20:16 EDT 2002


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.

Till we got the new compiler packages I have increased the buffersize to 100.000.

Marc, can you apply it and build a new compiler plz?


Mattias






More information about the Lazarus mailing list