]> git.ipfire.org Git - thirdparty/gcc.git/commit - libgfortran/ChangeLog
[libgfortran] Fix uninitialized variable use in fallback_access
authorKyrylo Tkachov <kyrylo.tkachov@arm.com>
Fri, 14 Sep 2018 09:22:01 +0000 (09:22 +0000)
committerKyrylo Tkachov <ktkachov@gcc.gnu.org>
Fri, 14 Sep 2018 09:22:01 +0000 (09:22 +0000)
commitef5057c89e636d7d566d52c06609a4615430e5b0
treeb69851d448758d64451837fb961a0bbf073c1922
parent7efd5ff31df5ac69a23b6285474f0b50154801f7
[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
libgfortran/ChangeLog
libgfortran/io/unix.c