[fpc-devel] 019605: Safety check for "const s: string" (similar to Range or Overflow checks)

Martin fpc at mfriebe.de
Thu Jun 23 23:24:05 CEST 2011

On 23/06/2011 22:13, Florian Klämpfl wrote:
> Am 23.06.2011 23:03, schrieb Martin:
>> And what exactly does checkpointer check?
> Check if the pointer points into a allocated memory block.
Ok, that would actually work.

even without  keep_released it could catch quite some

It should check, that it points to the correct place inside an allocated 
block (That is String^ := AllocAddr + SizeOf(StringLen) + SizeOf(StrRefCnt)

It could even check, that the refcount is not zero.
If the memory has not yet been reallocated, that should fail, if the 
string was released (assuming the last DecRefCnt, actually set's it to 
zero, before releasing the memory) (Would not work with -gt => since 
then all values are trashed)

It would definitely be a good start.

More information about the fpc-devel mailing list