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
fbuf.h
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
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
lock.c
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
transfer128.c
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
write_float.def
write.c