Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [patch] strlen(null) in dwarf2read
@ 2007-08-29 21:49 msnyder
  2007-09-04 14:25 ` Joel Brobecker
  0 siblings, 1 reply; 6+ messages in thread
From: msnyder @ 2007-08-29 21:49 UTC (permalink / raw)
  To: gdb-patches

[-- 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)

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2007-09-05  7:26 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-08-29 21:49 [patch] strlen(null) in dwarf2read msnyder
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox