Skip to content

Unsafe TIniFile (TStringList)

Original Reporter info from Mantis: BeniBela @benibela
  • Reporter name: Benito van der Zander

Description:

When a TIniFile updates the ini file, it calls TStringList.saveToFile, which calls TFileStream.Create(...,fmCreate) which open(..) with O_TRUNC flag, which DELETES all data in the ini file.

The writing of the new data can fail for any reason (disk full, system crash, program crash, especially Android kills apps at arbitrary times for resource reasons ) leaving us with a completely empty ini file .

(If a stream is used, ini file even explicitly deletes everything with Fstream.Size:=0;)

Mantis conversion info:

  • Mantis ID: 30439
  • Version: 3.0.0
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information