Hi Harald,
There are two possible fixes for this:
(1) guard the call to unlock_unit by:
diff --git a/libgfortran/io/transfer.c b/libgfortran/io/transfer.c
index cd51679ff46..296be0711a2 100644
--- a/libgfortran/io/transfer.c
+++ b/libgfortran/io/transfer.c
@@ -4508,7 +4508,8 @@ st_wait_async (st_parameter_wait *wtp)
async_wait (&(wtp->common), u->au);
}
- unlock_unit (u);
+ if (u)
+ unlock_unit (u);
}
(2) in unlock_unit():
diff --git a/libgfortran/io/unit.c b/libgfortran/io/unit.c
index 0030d7e8701..a3b0656cb90 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
Does anybody prefer one over the other, or just commit both (which might be
preferable to catch other unguarded cases)?
I think the second one is more robust - like you say, this may catch
other cases. If we have that one, we don't need the first one.
Regards
Thomas