diff options
author | Harald Anlauf <anlauf@gmx.de> | 2020-05-28 21:53:17 +0200 |
---|---|---|
committer | Harald Anlauf <anlauf@gmx.de> | 2020-05-28 21:53:17 +0200 |
commit | 6ce3d791dfcba469e709935aba5743640f7d4959 (patch) | |
tree | 9c9adb5687c17d19b73a9e70f8447553b522438e | |
parent | 7b599b9f9a1e036ff75a4daa06ac7036c6ebbe01 (diff) | |
download | gcc-6ce3d791dfcba469e709935aba5743640f7d4959.zip gcc-6ce3d791dfcba469e709935aba5743640f7d4959.tar.gz gcc-6ce3d791dfcba469e709935aba5743640f7d4959.tar.bz2 |
PR fortran/95104 - Segfault on a legal WAIT statement
The initial commit for this PR uncovered a latent issue with unit locking
in the Fortran run-time library. Add check for valid unit.
2020-05-28 Harald Anlauf <anlauf@gmx.de>
libgfortran/
PR libfortran/95104
* io/unit.c (unlock_unit): Guard by check for NULL pointer.
-rw-r--r-- | libgfortran/io/unit.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/libgfortran/io/unit.c b/libgfortran/io/unit.c index 0030d7e..a3b0656 100644 --- a/libgfortran/io/unit.c +++ b/libgfortran/io/unit.c @@ -767,9 +767,12 @@ close_unit_1 (gfc_unit *u, int locked) void unlock_unit (gfc_unit *u) { - NOTE ("unlock_unit = %d", u->unit_number); - UNLOCK (&u->lock); - NOTE ("unlock_unit done"); + if (u) + { + NOTE ("unlock_unit = %d", u->unit_number); + UNLOCK (&u->lock); + NOTE ("unlock_unit done"); + } } /* close_unit()-- Close a unit. The stream is closed, and any memory |