Commit e1396ee7 by Harald Anlauf

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.

(cherry picked from commit 6ce3d791dfcba469e709935aba5743640f7d4959)
parent c082cb8a
...@@ -767,9 +767,12 @@ close_unit_1 (gfc_unit *u, int locked) ...@@ -767,9 +767,12 @@ close_unit_1 (gfc_unit *u, int locked)
void void
unlock_unit (gfc_unit *u) unlock_unit (gfc_unit *u)
{ {
NOTE ("unlock_unit = %d", u->unit_number); if (u)
UNLOCK (&u->lock); {
NOTE ("unlock_unit done"); 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 /* close_unit()-- Close a unit. The stream is closed, and any memory
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment