Bugfix/Code Adjustment for TBinaryObjectReader lazarus / 7-LCL ---------------------------------------------------------------------- SiMozzer · 2004-08-18 22:32 Folks, I've just started to use and appreciate FPC & Lazarus and have found a small bug in TBinaryObjectReader. The bug can be reproduced by creating a TReader with::  TReader.Create(nil,BUFF_SIZE); { <- It is 'legal' to create a Tfiler assigned to a 'nil' stream                                                        but maybe a bit stupid )   try     ///... more code   finally      TReader.Free; // <- This line will cause an access violation   end;  The code crashes because the internal TBinaryObjectReader attempts to access the stream in its destrucrtor without first testing if it is assigned. The following adjustment prevents the GPF :: destructor TBinaryObjectReader.Destroy; begin   If Assigned(FStream) then  //<--- **test added here**     { Seek back the amount of bytes that we didn't process until now: }     FStream.Seek(Integer(FBufPos) - Integer(FBufEnd), soFromCurrent);   if Assigned(FBuffer) then     FreeMem(FBuffer, FBufSize);   inherited Destroy; end; what are your thoughts? R.E.S.P.E.C.T (jus like Franklin)) Si Mozzer ---------------------------------------------------------------------- Anonymous · 2004-10-14 22:44 What Can I think - happy bug hunter should submit a bugfix to merge into code...