From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20049 invoked by alias); 29 Aug 2007 21:49:56 -0000 Received: (qmail 20036 invoked by uid 22791); 29 Aug 2007 21:49:55 -0000 X-Spam-Check-By: sourceware.org Received: from a.mail.sonic.net (HELO a.mail.sonic.net) (64.142.16.245) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 29 Aug 2007 21:49:50 +0000 Received: from webmail.sonic.net (b.webmail.sonic.net [64.142.100.148]) by a.mail.sonic.net (8.13.8.Beta0-Sonic/8.13.7) with ESMTP id l7TLnmt8025686 for ; Wed, 29 Aug 2007 14:49:48 -0700 Received: from 12.7.175.2 (SquirrelMail authenticated user msnyder) by webmail.sonic.net with HTTP; Wed, 29 Aug 2007 14:49:48 -0700 (PDT) Message-ID: <15003.12.7.175.2.1188424188.squirrel@webmail.sonic.net> Date: Wed, 29 Aug 2007 21:49:00 -0000 Subject: [patch] strlen(null) in dwarf2read From: msnyder@sonic.net To: gdb-patches@sourceware.org User-Agent: SquirrelMail/1.4.9a MIME-Version: 1.0 Content-Type: multipart/mixed;boundary="----=_20070829144948_30530" Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2007-08/txt/msg00531.txt.bz2 ------=_20070829144948_30530 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit Content-length: 37 Not all strlens can deal with null. ------=_20070829144948_30530 Content-Type: text/plain; name="68.txt" Content-Transfer-Encoding: 8bit Content-Disposition: attachment; filename="68.txt" Content-length: 2583 2007-08-29 Michael Snyder * 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) ------=_20070829144948_30530--