public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "jvdelisle at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/31922] Accessing uninitialized variable for print *, trim(blank_string)
Date: Tue, 15 May 2007 02:38:00 -0000	[thread overview]
Message-ID: <20070515023844.9614.qmail@sourceware.org> (raw)
In-Reply-To: <bug-31922-13404@http.gcc.gnu.org/bugzilla/>



------- Comment #2 from jvdelisle at gcc dot gnu dot org  2007-05-15 03:38 -------
I think the correct place to fix this is in trim.  The uninitialized variable
is being passed to the library from trim.  Looking at the fdump-tree-original,
you can see that the variable ch is initialized by setting to all blanks.  Then
a temporary char pointer is set up to pass to trim which is called with a
temporary len which is set by trim to zero when it scans through the string of
blanks.

This patch fixes this.

Index: string_intrinsics.c
===================================================================
*** string_intrinsics.c (revision 124646)
--- string_intrinsics.c (working copy)
*************** string_trim (GFC_INTEGER_4 * len, void *
*** 171,176 ****
--- 171,178 ----
        /* copy string if necessary.  */
        memmove (*dest, src, *len);
      }
+   else
+     *dest = NULL;
  }

With this patch, valgrind gives a clean report and it regression tested fine. 
I also checked the result of the same operation to a file.

I will commit this to trunk as simple and obvious if you agree.


-- 


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


  parent reply	other threads:[~2007-05-15  2:38 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-05-14 18:25 [Bug fortran/31922] New: " burnus at gcc dot gnu dot org
2007-05-14 19:24 ` [Bug fortran/31922] " burnus at gcc dot gnu dot org
2007-05-15  2:38 ` jvdelisle at gcc dot gnu dot org [this message]
2007-05-15  7:52 ` burnus at gcc dot gnu dot org
2007-05-16  0:38 ` jvdelisle at gcc dot gnu dot org
2007-05-16  0:40 ` [Bug fortran/31922] [4.2 only] " jvdelisle at gcc dot gnu dot org
2007-05-20 23:00 ` jvdelisle at gcc dot gnu dot org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070515023844.9614.qmail@sourceware.org \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).