Gehe zu deutscher Webseite

ViaThinkSoft CodeLib

This article is in:
CodeLibProgramming aidsDelphi

The following record will cause memory corruptions (can be detected with FastMM4) because the reference counting of the string inside the record is not correctly handled anymore.

type
  TBuggy = record
    MyString: string;
  end;

Following change will fix the issue:

type
  TWorking = record
    Dummy: Cardinal;
    MyString: string;
  end;

Any additional member to the record will fix the issue.

Tested with Delphi 2007 Professional.
Daniel Marschall
ViaThinkSoft Co-Founder