This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB 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]

Re: [commit] dwarf2read.c (typename_concat): avoid segv


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?


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