gcc/libgfortran/io
Kyrylo Tkachov ef5057c89e [libgfortran] Fix uninitialized variable use in fallback_access
I've been tracking down a bug in a Fortran program on a newlib target and it boils down to fallback_access doing something bad.
The unconditional calls to close cause havoc when open doesn't get called due to the short-circuiting in the if-statement above
because the fd is uninitialised. In my environment GCC ends up calling close on file descriptor 0, thus trying to close stdin.

This patch tightens up the calling so that close is called only when the corresponding open call succeeded.
With this my runtime failure disappears.

Bootstrapped and tested on aarch64-none-linux-gnu.
Though that doesn't exercise this call I hope it's an obviously correct change. 

	* io/unix.c (fallback_access): Avoid calling close on
	uninitialized file descriptor.

From-SVN: r264305
2018-09-14 09:22:01 +00:00
..
async.c re PR fortran/25829 ([F03] Asynchronous IO support) 2018-08-21 18:48:59 +00:00
async.h * io/async.h: Use __gthread_mutex_t, not pthread_mutex_t. 2018-09-05 10:28:45 +00:00
close.c re PR fortran/25829 ([F03] Asynchronous IO support) 2018-08-21 18:48:59 +00:00
fbuf.c PR 78534, 83704 Handle large formatted I/O 2018-01-07 12:17:52 +02:00
fbuf.h PR 78534, 83704 Handle large formatted I/O 2018-01-07 12:17:52 +02:00
file_pos.c re PR fortran/25829 ([F03] Asynchronous IO support) 2018-08-21 18:48:59 +00:00
format.c io.h: Change declaration of vlist type to gfc_full_array_i4 to eliminate warning for... 2018-09-02 15:55:51 +00:00
format.h io.h: Change declaration of vlist type to gfc_full_array_i4 to eliminate warning for... 2018-09-02 15:55:51 +00:00
inquire.c re PR fortran/25829 ([F03] Asynchronous IO support) 2018-08-21 18:48:59 +00:00
intrinsics.c Update copyright years. 2018-01-03 11:03:58 +01:00
io.h io.h: Change declaration of vlist type to gfc_full_array_i4 to eliminate warning for... 2018-09-02 15:55:51 +00:00
list_read.c gfortran.h (gfc_dt): Rename default_exp field to dec_ext. 2018-03-28 13:59:06 +02:00
lock.c Update copyright years. 2018-01-03 11:03:58 +01:00
open.c re PR fortran/25829 ([F03] Asynchronous IO support) 2018-08-21 18:48:59 +00:00
read.c re PR fortran/25829 ([F03] Asynchronous IO support) 2018-08-21 18:48:59 +00:00
size_from_kind.c Update copyright years. 2018-01-03 11:03:58 +01:00
transfer128.c Update copyright years. 2018-01-03 11:03:58 +01:00
transfer.c re PR fortran/25829 ([F03] Asynchronous IO support) 2018-08-21 18:48:59 +00:00
unit.c re PR fortran/25829 ([F03] Asynchronous IO support) 2018-08-21 18:48:59 +00:00
unix.c [libgfortran] Fix uninitialized variable use in fallback_access 2018-09-14 09:22:01 +00:00
unix.h PR 78534, 83704 Handle large formatted I/O 2018-01-07 12:17:52 +02:00
write_float.def re PR libfortran/86070 (gfortran.dg/fmt_zero_digits.f90 segmentation fault starting with r261077) 2018-06-10 01:49:02 +00:00
write.c re PR fortran/85840 (Memory leak in write.c) 2018-05-28 21:55:31 +00:00