From 56f03cd12be26828788a27f6f3c250041a958e45 Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Tue, 26 May 2020 23:29:52 +0200 Subject: PR fortran/95104 - Segfault on a legal WAIT statement Referencing a unit in a WAIT statement that has not been opened before resulted in a NULL pointer dereference. Check for this condition. 2020-05-26 Harald Anlauf libgfortran/ PR libfortran/95104 * io/transfer.c (st_wait_async): Do not dereference NULL pointer. gcc/testsuite/ PR libfortran/95104 * gfortran.dg/pr95104.f90: New test. Co-Authored-By: Steven G. Kargl --- libgfortran/io/transfer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libgfortran/io') diff --git a/libgfortran/io/transfer.c b/libgfortran/io/transfer.c index d071c1c..cd51679 100644 --- a/libgfortran/io/transfer.c +++ b/libgfortran/io/transfer.c @@ -4500,7 +4500,7 @@ void st_wait_async (st_parameter_wait *wtp) { gfc_unit *u = find_unit (wtp->common.unit); - if (ASYNC_IO && u->au) + if (ASYNC_IO && u && u->au) { if (wtp->common.flags & IOPARM_WAIT_HAS_ID) async_wait_id (&(wtp->common), u->au, *wtp->id); -- cgit v1.1