This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/31922] Accessing uninitialized variable for print *, trim(blank_string)
- From: "burnus at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 14 May 2007 19:24:37 -0000
- Subject: [Bug fortran/31922] Accessing uninitialized variable for print *, trim(blank_string)
- References: <bug-31922-13404@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- 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