[Lazarus] EXC_BAD_ACCESS, Could not access memory

Roland Turcan konf at rotursoft.sk
Fri Apr 24 16:00:19 CEST 2009


<<< 24.4.2009 15:30 - Bogusław Brandys "brandys at o2.pl" >>>
BB> 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;

BB> How is HeaderLen declared ?

Stream.Read (HeaderLen, SIZEOF (HeaderLen));

where information header's length is stored into binary.

-- 
Best regards, TRoland
http://www.rotursoft.sk
http://exekutor.rotursoft.sk




More information about the Lazarus mailing list