https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65089
--- Comment #14 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> --- Author: jvdelisle Date: Wed Apr 15 01:27:03 2015 New Revision: 222111 URL: https://gcc.gnu.org/viewcvs?rev=222111&root=gcc&view=rev Log: 2015-04-14 Jerry DeLisle <jvdeli...@gcc.gnu.org> PR libgfortran/65089 * io/format.h (free_format): New function to free memory allocated for building format error messages. * io/format.c (format_error): Add checks before freeing memory to avoid potential segfaults and free formatting data when needed on error conditions. Always allocate and NULL terminate the string. * io/transfer.c (st_read_done, st_write_done): Use new free_format function to clean up memory allocations when done. Modified: trunk/libgfortran/ChangeLog trunk/libgfortran/io/format.c trunk/libgfortran/io/format.h trunk/libgfortran/io/transfer.c