Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Kevin Buettner <kevinb@redhat.com>
To: gdb-patches@sources.redhat.com
Subject: Re: [PATCH] solib_open, memory leak
Date: Mon, 06 Aug 2007 22:39:00 -0000	[thread overview]
Message-ID: <20070806153901.37fe366b@ironwood.lan> (raw)
In-Reply-To: <m3y7go47sj.fsf@codesourcery.com>

On Mon, 06 Aug 2007 15:28:28 -0700
Jim Blandy <jimb@codesourcery.com> wrote:

> Even if you've made sure that temp_pathname is malloc'd by the time we
> reach the 'open', any later 'openp' call will throw away its value.
> openp is careful to store *something* in the pointer referred to by
> its last argument, even on error.
> 
> I think the invariant should be that, when found_file becomes >= 0,
> then temp_pathname is malloc'd, and not before.  The 'openp' clauses
> will preserve that.  So I think you need:
> 
>   if (found_file >= 0)
>     temp_pathname = xstrdup (temp_pathname);
> 
> after the 'open'.
> 
> And then there's no need for the xstrdup at the bottom; just return
> temp_pathname, or xfree it if the caller doesn't want it.

Jim's analysis looks right to me.

Kevin


  reply	other threads:[~2007-08-06 22:39 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-08-05  3:17 msnyder
2007-08-06 22:28 ` Jim Blandy
2007-08-06 22:39   ` Kevin Buettner [this message]
2007-08-08 18:29   ` msnyder
2007-08-08 21:46     ` Jim Blandy
2007-08-08 21:58       ` msnyder
2007-08-08 22:08         ` Jim Blandy
2007-08-09 18:37           ` msnyder

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=20070806153901.37fe366b@ironwood.lan \
    --to=kevinb@redhat.com \
    --cc=gdb-patches@sources.redhat.com \
    /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