[Lazarus] EXC_BAD_ACCESS, Could not access memory

dmitry boyarintsev skalogryz.lists at gmail.com
Fri Apr 24 15:11:25 CEST 2009

> Hm?

TYPE TSomethingArr = ARRAY OF TSomeItem;

declares a dynamic arrays. Dynamic arrays are implicit pointers, so
should be used carefully in streaming operations.

this should fix your problem:

FUNCTION TMyObject.LoadFromStream (Stream:TStream):BOOLEAN;
 SetLength (FItems, 0);
 // make sure, that length of (FHeader) is greater than zero,
 // otherwise it will cause another exception
 Stream.Read (FHeader[0], HeaderLen);
 SetLength (FItems, 0);


More information about the Lazarus mailing list