[fpc-pascal] TIniFile crash/memory loss

DaWorm daworm at gmail.com
Fri Apr 1 14:45:38 CEST 2011


On Fri, Apr 1, 2011 at 6:28 AM, José Mejuto <joshyfun at gmail.com> wrote:
> An exception in free is an extreme rare condition, but it could
> happend, and is better that your software stops to work than notify 2
> years later that your 2 zillions of INI files were not written at all
> because the user write a non valid file path.

The test case was an invalid filename.  Is this the primary failure
method?  If so, then check this in the create, or the first write, (or
check any other reasons why writing to the file would fail) and throw
the exception there.  Then you should rarely if ever get to the
destructor with an unwritable file. Sure, someone could change the
permissions on you between the create and the destroy, but how likely
is that?

Jeff.



More information about the fpc-pascal mailing list