[Lazarus] EXC_BAD_ACCESS, Could not access memory
Bogusław Brandys
brandys at o2.pl
Fri Apr 24 15:30:20 CEST 2009
Roland Turcan pisze:
> Hello Bart and others,
>
> Thanks for your kindness to test my test case, which works fine in my
> case too, but I have found something what maybe more explain my
> problem.
>
> TYPE TSomeItem = RECORD
> First :single;
> Second:Single;
> Third :integer;
>
> TYPE TSomethingArr = ARRAY OF TSomeItem;
>
> TYPE TSomeHeader =RECORD
> ...
> end;
>
> TYPE TMyObject =class
> private
> FHeader:TSomeHeader;
> FItems :TSomethingArr;
>
> ...
>
> FUNCTION TMyObject.LoadFromStream (Stream:TStream):BOOLEAN;
> ...
> SetLength (FItems, 0); //!! for testing only -- this line works fine
> Stream.Read (FHeader, HeaderLen);
> SetLength (FItems, 0); //!! for testing only -- this line raises an exception
> END;
>
>
> If you see the declaration of TMyObject you will find that FHeader
> declaration is followed by FItems and the length of read memory block
> goes over size of FHeader and it affects FItems.
>
> Hm?
>
> TRoland;
How is HeaderLen declared ?
Boguslaw
More information about the Lazarus
mailing list