jgabaut / koliseo

An arena allocator library in C.
https://jgabaut.github.io/koliseo-docs
GNU General Public License v3.0
5 stars 0 forks source link

File pointer for debug log is not closed on some exit calls #33

Closed jgabaut closed 10 months ago

jgabaut commented 12 months ago

From version 0.3.0, (see PR), a FIXME has been put in place at the beginning of koliseo.c.

Right now, calls to exit() from runtime error checks never try to fclose(KOLISEO_DEBUG_FP). As a result, if it is initialised, it can leak when an error (say, Out-of-memory) happens.

This should be corrected because even if the lib doesn't initialise the pointer, it could still be made ready from calling code.

jgabaut commented 11 months ago

With version 0.3.1, (see PR), kls_new_traced() is provided to correctly init a Koliseo which performs the required fclose() inside kls_free().

However, there are still many exit() statements that can be reached with no kls_free() call before. I will have to see if something can be done about it.

jgabaut commented 10 months ago

I guess on POSIX, we should just trust the kernel to close the file when we do exit(). For Windows, check this out: link.

Closing for now.