Skip to content

TBoldTypeNameMapping.SetAsString frees Self instead of TStringList #41

@bero

Description

@bero

Problem

TBoldTypeNameMapping.SetAsString in BoldTypeNameDictionary.pas calls Free (which is Self.Free) instead of vTmpList.Free. This destroys the mapping object itself and leaks the TStringList.

  procedure TBoldTypeNameMapping.SetAsString(const Value: string);
  var
    vTmpList: TStringList;
  begin
    vTmpList := TStringList.Create;
    try
      vTmpList.CommaText := value;
      // ... assigns all fields from vTmpList ...
    finally
      Free;           // BUG: frees Self (TBoldTypeNameMapping)
    end;              // should be: vTmpList.Free
  end;

Impact

Any code path that calls SetAsString (via the AsString property) crashes with an Access Violation:

  • TBoldTypeNameDictionary.LoadFromFile
  • TBoldTypeNameDictionary.LoadFromStringList

SaveToFile is unaffected (uses GetAsString).

Fix

Change Free to vTmpList.Free.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions