gcc/libgfortran
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
..
caf
config
generated re PR fortran/86704 (Segmentation fault when using matmul in combination with transpose) 2018-08-25 21:31:30 +00:00
ieee
intrinsics Include <sys/random.h> for getentropy on Solaris 2018-08-14 22:51:36 +00:00
io [libgfortran] Fix uninitialized variable use in fallback_access 2018-09-14 09:22:01 +00:00
m4 re PR fortran/86704 (Segmentation fault when using matmul in combination with transpose) 2018-08-25 21:31:30 +00:00
runtime Fix interleaving of Fortran STOP messages 2018-09-12 13:53:34 +00:00
acinclude.m4
aclocal.m4
c99_protos.h
ChangeLog [libgfortran] Fix uninitialized variable use in fallback_access 2018-09-14 09:22:01 +00:00
ChangeLog-2002
ChangeLog-2003
ChangeLog-2004
ChangeLog-2005
ChangeLog-2006
ChangeLog-2007
ChangeLog-2008
ChangeLog-2009
ChangeLog-2010
ChangeLog-2011
ChangeLog-2012
ChangeLog-2013
ChangeLog-2014
ChangeLog-2015
ChangeLog-2016
ChangeLog-2017
config.h.in Include <sys/random.h> for getentropy on Solaris 2018-08-14 22:51:36 +00:00
configure Include <sys/random.h> for getentropy on Solaris 2018-08-14 22:51:36 +00:00
configure.ac Include <sys/random.h> for getentropy on Solaris 2018-08-14 22:51:36 +00:00
configure.host
gfortran.map re PR fortran/25829 ([F03] Asynchronous IO support) 2018-08-21 18:48:59 +00:00
kinds-override.h
libgfortran.h re PR fortran/25829 ([F03] Asynchronous IO support) 2018-08-21 18:48:59 +00:00
libgfortran.spec.in
libtool-version
Makefile.am re PR fortran/25829 ([F03] Asynchronous IO support) 2018-08-21 18:48:59 +00:00
Makefile.in re PR fortran/25829 ([F03] Asynchronous IO support) 2018-08-21 18:48:59 +00:00
mk-kinds-h.sh
mk-sik-inc.sh
mk-srk-inc.sh