Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom Tromey <tromey@redhat.com>
To: Pedro Alves <pedro@codesourcery.com>
Cc: gdb-patches@sourceware.org
Subject: Re: RFA: fix PR gdb/2489
Date: Tue, 03 Feb 2009 19:20:00 -0000	[thread overview]
Message-ID: <m3y6wnib1n.fsf@fleche.redhat.com> (raw)
In-Reply-To: <m3y6wol2st.fsf@fleche.redhat.com> (Tom Tromey's message of "Mon\, 02 Feb 2009 18\:36\:18 -0700")

>>>>> "Tom" == Tom Tromey <tromey@redhat.com> 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  <tromey@redhat.com>

	* 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;


      reply	other threads:[~2009-02-03 19:20 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-01 19:15 Tom Tromey
2008-10-21 22:25 ` Pedro Alves
2009-02-03  1:02   ` Tom Tromey
2009-02-03  1:10     ` Tom Tromey
2009-02-03  1:20     ` Pedro Alves
2009-02-03  1:38       ` Tom Tromey
2009-02-03 19:20         ` Tom Tromey [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m3y6wnib1n.fsf@fleche.redhat.com \
    --to=tromey@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=pedro@codesourcery.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox