Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: msnyder@sonic.net
To: gdb-patches@sourceware.org
Subject: [patch] strlen(null) in dwarf2read
Date: Wed, 29 Aug 2007 21:49:00 -0000	[thread overview]
Message-ID: <15003.12.7.175.2.1188424188.squirrel@webmail.sonic.net> (raw)

[-- Attachment #1: Type: text/plain, Size: 37 bytes --]

Not all strlens can deal with null.


[-- Attachment #2: 68.txt --]
[-- Type: text/plain, Size: 2583 bytes --]

2007-08-29  Michael Snyder  <msnyder@access-company.com>

	* dwarf2read.c (determine_prefix): Do not send NULL to strlen.

Index: dwarf2read.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2read.c,v
retrieving revision 1.230
diff -p -r1.230 dwarf2read.c
*** dwarf2read.c	23 Aug 2007 18:08:28 -0000	1.230
--- dwarf2read.c	29 Aug 2007 21:45:22 -0000
*************** determine_prefix (struct die_info *die, 
*** 7677,7696 ****
  }
  
  /* 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 = ".";
--- 7677,7703 ----
  }
  
  /* 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;
  
!   /* Do not ask strlen to deal with a null pointer!  */
!   if (suffix == NULL)
!     suffix = "";
!   if (prefix == NULL)
!     prefix = "";
! 
!   if (suffix[0] == '\0' || prefix[0] == '\0')
      sep = "";
    else if (cu->language == language_java)
      sep = ".";
*************** typename_concat (struct obstack *obs, co
*** 7699,7705 ****
  
    if (obs == NULL)
      {
!       char *retval = xmalloc (strlen (prefix) + MAX_SEP_LEN + strlen (suffix) + 1);
        retval[0] = '\0';
        
        if (prefix)
--- 7706,7713 ----
  
    if (obs == NULL)
      {
!       char *retval = 
! 	xmalloc (strlen (prefix) + MAX_SEP_LEN + strlen (suffix) + 1);
        retval[0] = '\0';
        
        if (prefix)

             reply	other threads:[~2007-08-29 21:49 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-08-29 21:49 msnyder [this message]
2007-09-04 14:25 ` Joel Brobecker
2007-09-05  0:10   ` msnyder
2007-09-05  0:53     ` Daniel Jacobowitz
2007-09-05  1:11       ` msnyder
2007-09-05  7:26     ` Mark Kettenis

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=15003.12.7.175.2.1188424188.squirrel@webmail.sonic.net \
    --to=msnyder@sonic.net \
    --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