Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: "Doug Evans" <dje@google.com>
To: gdb-patches@sourceware.org
Subject: Re: [commit] dwarf2read.c (typename_concat): avoid segv
Date: Fri, 24 Oct 2008 18:57:00 -0000	[thread overview]
Message-ID: <e394668d0810241156o5ba883c5re15cc8c22319c930@mail.gmail.com> (raw)
In-Reply-To: <20081024184719.GA8460@caradoc.them.org>

On Fri, Oct 24, 2008 at 11:47 AM, Daniel Jacobowitz <drow@false.org> wrote:
> On Fri, Oct 24, 2008 at 02:43:01PM -0400, Daniel Jacobowitz wrote:
>> If NULL values are valid, this change is definitely not correct.
>> You've changed a NULL prefix and "foo" suffix from "foo" to "::foo".
>
> "Definitely" is too strong... I see that we differed with and without
> an obstack :-(

Heh.  After I sent the message I knew I should have added a followup
pointing out that the segv is in the obs != NULL case.  Blech.

typename_concat has this:

/* Return a newly-allocated string formed by concatenating PREFIX and
   SUFFIX with appropriate separator.  If PREFIX or SUFFIX is NULL or
empty, then
   simply copy the SUFFIX or PREFIX, respectively.  If OBS is
non-null,
   perform an obconcat, otherwise allocate storage for the result.
The CU argument
   is used to determine the language and hence, the appropriate separator.  */

#define MAX_SEP_LEN 2  /* sizeof ("::")  */

static char *
typename_concat (struct obstack *obs, const char *prefix, const char *suffix,
                 struct dwarf2_cu *cu)
{
  char *sep;

  if (suffix == NULL || suffix[0] == '\0' || prefix == NULL ||
prefix[0] == '\0')
    sep = "";
  else if (cu->language == language_java)
    sep = ".";
  else
    sep = "::";


Given that, I think my patch is correct (unless one wants to require
callers to not pass NULL any longer).  Am I missing something?


  reply	other threads:[~2008-10-24 18:57 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-24 18:26 Doug Evans
2008-10-24 18:43 ` Daniel Jacobowitz
2008-10-24 18:48   ` Daniel Jacobowitz
2008-10-24 18:57     ` Doug Evans [this message]
2008-10-24 19:01       ` Daniel Jacobowitz

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=e394668d0810241156o5ba883c5re15cc8c22319c930@mail.gmail.com \
    --to=dje@google.com \
    --cc=gdb-patches@sourceware.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