From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11402 invoked by alias); 3 Feb 2009 19:20:55 -0000 Received: (qmail 11390 invoked by uid 22791); 3 Feb 2009 19:20:54 -0000 X-SWARE-Spam-Status: No, hits=-2.3 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mx2.redhat.com (HELO mx2.redhat.com) (66.187.237.31) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 03 Feb 2009 19:20:49 +0000 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n13JIlur010648; Tue, 3 Feb 2009 14:18:47 -0500 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n13JIk96001414; Tue, 3 Feb 2009 14:18:47 -0500 Received: from opsy.redhat.com (vpn-13-51.rdu.redhat.com [10.11.13.51]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n13JIkaJ012515; Tue, 3 Feb 2009 14:18:46 -0500 Received: by opsy.redhat.com (Postfix, from userid 500) id CB9145080FB; Tue, 3 Feb 2009 12:18:44 -0700 (MST) To: Pedro Alves Cc: gdb-patches@sourceware.org Subject: Re: RFA: fix PR gdb/2489 References: <200810212324.38183.pedro@codesourcery.com> <200902030121.48729.pedro@codesourcery.com> From: Tom Tromey Reply-To: Tom Tromey Date: Tue, 03 Feb 2009 19:20:00 -0000 In-Reply-To: (Tom Tromey's message of "Mon\, 02 Feb 2009 18\:36\:18 -0700") Message-ID: User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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: 2009-02/txt/msg00076.txt.bz2 >>>>> "Tom" == Tom Tromey writes: Tom> Anyway, I suspect that you are correct, and we could see a NULL here, Tom> but I don't know how to make it happen. I will add a check for NULL Tom> here tomorrow. I am checking in the appended to address this potential problem. Built and regtested on x86-64 (compile farm). thanks, Tom 2009-02-03 Tom Tromey * completer.c (add_struct_fields): Check type_name against NULL before use. diff --git a/gdb/completer.c b/gdb/completer.c index 5d7225f..298cdd0 100644 --- a/gdb/completer.c +++ b/gdb/completer.c @@ -371,6 +371,7 @@ add_struct_fields (struct type *type, int *nextp, char **output, char *fieldname, int namelen) { int i; + int computed_type_name = 0; char *type_name = NULL; CHECK_TYPEDEF (type); @@ -392,10 +393,13 @@ add_struct_fields (struct type *type, int *nextp, char **output, char *name = TYPE_FN_FIELDLIST_NAME (type, i); if (name && ! strncmp (name, fieldname, namelen)) { - if (!type_name) - type_name = type_name_no_tag (type); + if (!computed_type_name) + { + type_name = type_name_no_tag (type); + computed_type_name = 1; + } /* Omit constructors from the completion list. */ - if (strcmp (type_name, name)) + if (type_name && strcmp (type_name, name)) { output[*nextp] = xstrdup (name); ++*nextp;