From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18429 invoked by alias); 14 Aug 2007 04:19:07 -0000 Received: (qmail 18191 invoked by uid 22791); 14 Aug 2007 04:19:05 -0000 X-Spam-Check-By: sourceware.org Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.31) with ESMTP; Tue, 14 Aug 2007 04:19:03 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 1E36C2AA1D8; Tue, 14 Aug 2007 00:19:01 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 9l0o-nq2JMIj; Tue, 14 Aug 2007 00:19:01 -0400 (EDT) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id BC4F82AA1D5; Tue, 14 Aug 2007 00:19:00 -0400 (EDT) Received: by joel.gnat.com (Postfix, from userid 1000) id D3B95E7B54; Mon, 13 Aug 2007 21:22:42 -0700 (PDT) Date: Tue, 14 Aug 2007 04:19:00 -0000 From: Joel Brobecker To: msnyder@sonic.net Cc: gdb-patches@sourceware.org Subject: Re: [PATCH] ada-lang.c, null pointer Message-ID: <20070814042242.GA11498@adacore.com> References: <8146.12.7.175.2.1186864158.squirrel@webmail.sonic.net> <25376.12.7.175.2.1186864263.squirrel@webmail.sonic.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="0F1p//8PRICkK4MW" Content-Disposition: inline In-Reply-To: <25376.12.7.175.2.1186864263.squirrel@webmail.sonic.net> User-Agent: Mutt/1.4.2.2i 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/msg00277.txt.bz2 --0F1p//8PRICkK4MW Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 1181 Hi Michael, > 2007-08-11 Michael Snyder > > * ada-lang.c (field_alignment): Guard against NULL. Thanks again for your patch. May I propose another patch that is very close in spirit? The diff is slightly bigger, but it makes the code check for a null name only once, and allows us to know at a glance what we do in this case. Let me know what you think. (proposed patch reg-tested) > Index: ada-lang.c > =================================================================== > RCS file: /cvs/src/src/gdb/ada-lang.c,v > retrieving revision 1.100 > diff -p -r1.100 ada-lang.c > *** ada-lang.c 6 Aug 2007 20:07:44 -0000 1.100 > --- ada-lang.c 11 Aug 2007 20:25:00 -0000 > *************** field_alignment (struct type *type, int > *** 6119,6125 **** > int len = (name == NULL) ? 0 : strlen (name); > int align_offset; > > ! if (!isdigit (name[len - 1])) > return 1; > > if (isdigit (name[len - 2])) > --- 6119,6125 ---- > int len = (name == NULL) ? 0 : strlen (name); > int align_offset; > > ! if (name == NULL || !isdigit (name[len - 1])) > return 1; > > if (isdigit (name[len - 2])) -- Joel --0F1p//8PRICkK4MW Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="ada-lang.c.diff" Content-length: 789 Index: ada-lang.c =================================================================== RCS file: /cvs/src/src/gdb/ada-lang.c,v retrieving revision 1.100 diff -u -p -r1.100 ada-lang.c --- ada-lang.c 6 Aug 2007 20:07:44 -0000 1.100 +++ ada-lang.c 14 Aug 2007 03:45:04 -0000 @@ -6116,9 +6116,17 @@ static unsigned int field_alignment (struct type *type, int f) { const char *name = TYPE_FIELD_NAME (type, f); - int len = (name == NULL) ? 0 : strlen (name); + int len; int align_offset; + /* The field name should never be null, unless the debugging information + is somehow malformed. In this case, we assume the field does not + require any alignment. */ + if (name == NULL) + return 1; + + len = strlen (name); + if (!isdigit (name[len - 1])) return 1; --0F1p//8PRICkK4MW--