From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2020 invoked by alias); 2 Aug 2007 21:30:14 -0000 Received: (qmail 2011 invoked by uid 22791); 2 Aug 2007 21:30:12 -0000 X-Spam-Check-By: sourceware.org Received: from b.mail.sonic.net (HELO b.mail.sonic.net) (64.142.19.5) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 02 Aug 2007 21:30:04 +0000 Received: from webmail.sonic.net (b.webmail.sonic.net [64.142.100.148]) by b.mail.sonic.net (8.13.8.Beta0-Sonic/8.13.7) with ESMTP id l72LU0t2029010; Thu, 2 Aug 2007 14:30:00 -0700 Received: from 12.7.175.2 (SquirrelMail authenticated user msnyder) by webmail.sonic.net with HTTP; Thu, 2 Aug 2007 14:30:01 -0700 (PDT) Message-ID: <12786.12.7.175.2.1186090201.squirrel@webmail.sonic.net> In-Reply-To: <655C3D4066B7954481633935A40BB36F22BA4C@ussunex02.svl.access-company.c om> References: <12757.12.7.175.2.1185924312.squirrel@webmail.sonic.net> <20070802210606.GF6563@caradoc.them.org> <655C3D4066B7954481633935A40BB36F22BA4C@ussunex02.svl.access-company.com> Date: Thu, 02 Aug 2007 21:30:00 -0000 Subject: Re: FW: [PATCH] jv-lang, guard against NULL From: msnyder@sonic.net To: gdb-patches@sourceware.org Cc: drow@false.org User-Agent: SquirrelMail/1.4.9a MIME-Version: 1.0 Content-Type: multipart/mixed;boundary="----=_20070802143001_25378" 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/msg00026.txt.bz2 ------=_20070802143001_25378 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit Content-length: 651 > > On Tue, Jul 31, 2007 at 04:25:12PM -0700, Michael Snyder wrote: >> ! if (name != NULL && (i = strlen (name)) > 2 >> ! && name[i - 1] == ']' && tsuper != NULL) > > Can we avoid assignments inside the if statement? Yeah, I tried, but it ended up looking really awkward. Test 'name', then do the strlen, then test name again. > Also, there's an > unprotected call to strrchr above. Maybe this should be an assert > instead, at the top of the function. Good idea -- except, can we really be sure that name can never legitimately be null? Oh, yeah, I guess the unprotected strrchr sort of tells us that, doesn't it? OK, how about this? ------=_20070802143001_25378 Content-Type: text/plain; name="255b.txt" Content-Transfer-Encoding: 8bit Content-Disposition: attachment; filename="255b.txt" Content-length: 1403 2007-07-31 Michael Snyder * jv-lang.c (java_link_class_type): Guard against NULL. Index: jv-lang.c =================================================================== RCS file: /cvs/src/src/gdb/jv-lang.c,v retrieving revision 1.47 diff -p -r1.47 jv-lang.c *** jv-lang.c 13 Jun 2007 17:30:01 -0000 1.47 --- jv-lang.c 2 Aug 2007 21:29:07 -0000 *************** java_link_class_type (struct type *type, *** 351,363 **** struct objfile *objfile = get_dynamics_objfile (); struct type *tsuper; unqualified_name = strrchr (name, '.'); if (unqualified_name == NULL) unqualified_name = name; temp = clas; temp = value_struct_elt (&temp, NULL, "superclass", NULL, "structure"); ! if (name != NULL && strcmp (name, "java.lang.Object") == 0) { tsuper = get_java_object_type (); if (tsuper && TYPE_CODE (tsuper) == TYPE_CODE_PTR) --- 351,364 ---- struct objfile *objfile = get_dynamics_objfile (); struct type *tsuper; + gdb_assert (name != NULL); unqualified_name = strrchr (name, '.'); if (unqualified_name == NULL) unqualified_name = name; temp = clas; temp = value_struct_elt (&temp, NULL, "superclass", NULL, "structure"); ! if (strcmp (name, "java.lang.Object") == 0) { tsuper = get_java_object_type (); if (tsuper && TYPE_CODE (tsuper) == TYPE_CODE_PTR) ------=_20070802143001_25378--