------- Additional Comments From tkoenig at gcc dot gnu dot org 2005-08-15
22:12 -------
Proposed fix:
Index: transfer.c
===================================================================
RCS file: /cvs/gcc/gcc/libgfortran/io/transfer.c,v
retrieving revision 1.52
diff -c -p -r1.52 transfer.c
*** transfer.c 9 Aug 2005 01:56:04 -0000 1.52
--- transfer.c 15 Aug 2005 22:05:20 -0000
*************** data_transfer_init (int read_flag)
*** 1163,1168 ****
--- 1163,1177 ----
if (g.mode == READING && current_unit->mode == WRITING)
flush(current_unit->s);
+ /* Check whether the record number exists on reading. */
+
+ if (g.mode == READING
+ && ioparm.rec * current_unit->recl > file_length (current_unit->s))
+ {
+ generate_error (ERROR_BAD_OPTION, "Non-existing record number");
+ return;
+ }
+
/* Position the file. */
if (sseek (current_unit->s,
(ioparm.rec - 1) * current_unit->recl) == FAILURE)
Regression testing etc. to follow.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23321