This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug fortran/31922] Accessing uninitialized variable for print *, trim(blank_string)



------- Comment #1 from burnus at gcc dot gnu dot org  2007-05-14 20:24 -------
Jerry, you are one of the libgfortran/IO experts, could you have a look?


  _gfortran_transfer_character (&dt_parm.0, pstr.1, len.2);

uses uninitialized memory if len = 0 and p = NULL. This happens because
empty_string is not initialized to anything and points to a random position.
However, it is later tested for "p == NULL".


transfer_character (st_parameter_dt *dtp, void *p, int len)
{
  static char *empty_string[0];
[..]
  if (len == 0 && p == NULL)
    p = empty_string;
  dtp->u.p.transfer (dtp, BT_CHARACTER, p, len, len, 1);

And in:

formatted_transfer_scalar (st_parameter_dt *dtp, bt type, void *p, int len,
  n = (p == NULL) ? 0 : ((type != BT_COMPLEX) ? 1 : 2);

Would be the following a correctly working alternative?
  static char empty_string[0];
  if (len == 0 && p == NULL)
    p = &empty_string;


-- 

burnus at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jvdelisle at gcc dot gnu dot
                   |                            |org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31922


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]