diff options
Diffstat (limited to 'libgfortran/io/transfer.c')
-rw-r--r-- | libgfortran/io/transfer.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/libgfortran/io/transfer.c b/libgfortran/io/transfer.c index 902c020..7696cca 100644 --- a/libgfortran/io/transfer.c +++ b/libgfortran/io/transfer.c @@ -2601,7 +2601,15 @@ data_transfer_init (st_parameter_dt *dtp, int read_flag) dtp->u.p.current_unit = get_unit (dtp, 1); - if (dtp->u.p.current_unit->s == NULL) + if (dtp->u.p.current_unit == NULL) + { + /* This means we tried to access an external unit < 0 without + having opened it first with NEWUNIT=. */ + generate_error (&dtp->common, LIBERROR_BAD_OPTION, + "Invalid unit number in statement"); + return; + } + else if (dtp->u.p.current_unit->s == NULL) { /* Open the unit with some default flags. */ st_parameter_open opp; unit_convert conv; |