Ping: If no objection, I will commit to trunk on Wednesday evening.
On 12/10/2017 07:55 PM, Jerry DeLisle wrote:
> Hi all,
>
> While doing addition testing for the subject mentioned PR I discovered
> numerous
> un-freed memory allocations. I reported the problem in comment 30 of the PR.
>
> The attached patch cleans this up by opening the internal unit structures
> during
> program initialization and allowing the automatic closure similar to
> pre-connected units. The internal stream structures are created and freed at
> the
> beginning and end of each I/O operation. I fix a few loose ends.
>
> Regression tested on x86_64.
>
> OK for trunk? Also needed for same issue in 7.
>
> Regards,
>
> Jerry
>
> 2017-12-11 Jerry DeLisle <jvdeli...@gcc.gnu.org>
>
> PR libgfortran/78549
> * io/inquire.c (inquire_via_unit): Adjust test for existence for
> pre-connected internal units.
> * io/transfer.c (finalize_transfer): When done with a transfer
> to internal units, free the format buffer and close the stream.
> (st_read_done): Delete freeing the stream, now handled using
> sclose in finalize_transfer. (st_write_done): Likewise.
> * io/unit.c (get_unit): Return NULL for special reserved unit
> numbers, signifying not accessible to the user.
> (init_units): Insert the two special internal units into the
> unit treap. This makes these unit structures available without
> further allocations for later use by internal unit I/O. These
> units are automatically deleted by normal program termination.
> * unix.c (mem_close): Add a guard check to protect from double free.
>