public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [patch,libgfortran] PR88776 Namelist read from stdin: loss of data
@ 2019-01-12 22:35 Jerry DeLisle
  2019-01-14  0:18 ` Jerry DeLisle
  0 siblings, 1 reply; 2+ messages in thread
From: Jerry DeLisle @ 2019-01-12 22:35 UTC (permalink / raw)
  To: fortran; +Cc: GCC Patches

[-- Attachment #1: Type: text/plain, Size: 693 bytes --]

Hi all,

As stated in the PR, the problem turns out to be an ungraceful return 
after an error.  Most namelist errors go through nml_err_ret, The one I 
am removing did not and in the unique case of UNIT=5 after the error it 
falls through and hits some code which modifies pointers to the namelist 
data structures.

This patch fixes it.

Regression tested on x86-64 and manually tested with a redirection to 
stdin. (cat somefile | ./a.out )

I plan to commit today as simple along with a new testcase.

Regards.

Jerry

2019-01-12  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libfortran/88776
	* io/list_read.c (namelist_read): Use nml_err_ret path on
	read error, not based on stdin_unit.

[-- Attachment #2: pr88776.diff --]
[-- Type: text/x-patch, Size: 670 bytes --]

diff --git a/libgfortran/io/list_read.c b/libgfortran/io/list_read.c
index 4a7ccb3ddd5..d9af255a034 100644
--- a/libgfortran/io/list_read.c
+++ b/libgfortran/io/list_read.c
@@ -3614,11 +3614,7 @@ find_nml_name:
   while (!dtp->u.p.input_complete)
     {
       if (!nml_get_obj_data (dtp, &prev_nl, nml_err_msg, sizeof nml_err_msg))
-	{
-	  if (dtp->u.p.current_unit->unit_number != options.stdin_unit)
-	    goto nml_err_ret;
-	  generate_error (&dtp->common, LIBERROR_READ_VALUE, nml_err_msg);
-        }
+	goto nml_err_ret;
 
       /* Reset the previous namelist pointer if we know we are not going
 	 to be doing multiple reads within a single namelist object.  */

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-01-14  0:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-12 22:35 [patch,libgfortran] PR88776 Namelist read from stdin: loss of data Jerry DeLisle
2019-01-14  0:18 ` Jerry DeLisle

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).