[fpc-pascal] TIniFile crash/memory loss

José Mejuto joshyfun at gmail.com
Fri Apr 1 17:32:20 CEST 2011

Hello FPC-Pascal,

Friday, April 1, 2011, 2:45:38 PM, you wrote:

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

The "problem" is not in the concrete object, the "problem" is if a
.free can/shoud raise an exception or not. My idea is that it is not
desirable if it can be avoided, but if something does not do whichever
it is being designed for, it must raise an exception or the programmer
will never notice that something unexpected has happend.

Best regards,

More information about the fpc-pascal mailing list