re PR libfortran/16080 (segmentation fault when reading empty string)

2004-06-19  Bud Davis  <bdavis9659@comcast.net>

      PR gfortran/16080
      * gfortran.fortran-torture/execute/read_null_string.f90: New file.
      * io/list_read.c(set_value): don't copy if the string is null.

From-SVN: r83388
This commit is contained in:
Bud Davis 2004-06-19 16:42:05 +00:00 committed by Bud Davis
parent bb60c95fac
commit 04b0faec08
4 changed files with 32 additions and 2 deletions

View File

@ -1,3 +1,8 @@
2004-06-19 Bud Davis <bdavis9659@comcast.net>
PR gfortran/16080
* gfortran.fortran-torture/execute/read_null_string.f90: New file.
2004-06-19 Andrew Pinski <pinskia@physics.uc.edu>
* g++.dg/lookup/crash3.C: Use __SIZE_TYPE__

View File

@ -0,0 +1,15 @@
! pr 16080, segfault on reading an empty string
implicit none
integer t
character*20 temp_name
character*2 quotes
open(unit=7,status='SCRATCH')
quotes = '""""' ! "" in the file
write(7,*)1
write(7,'(A)')quotes
temp_name = 'hello' ! make sure the read overwrites it
rewind(7)
read(7, *) t
read(7, *) temp_name
if (temp_name.ne.'') call abort
end

View File

@ -1,3 +1,8 @@
2004-06-19 Bud Davis <bdavis9659@comcast.net>
PR gfortran/16080
* io/list_read.c(set_value): don't copy if the string is null.
2004-06-14 Bud Davis <bdavis9659@comcast.net>
PR gfortran/15292

View File

@ -1313,8 +1313,13 @@ set_value:
break;
case BT_CHARACTER:
m = (len < saved_used) ? len : saved_used;
memcpy (p, saved_string, m);
if (saved_string)
{
m = (len < saved_used) ? len : saved_used;
memcpy (p, saved_string, m);
}
else /* just delimeters encountered, nothing to copy but SPACE */
m = 0;
if (m < len)
memset (((char *) p) + m, ' ', len - m);