]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
PR c++/16597
authorKeith Seitz <keiths@redhat.com>
Wed, 16 Apr 2014 21:12:22 +0000 (14:12 -0700)
committerKeith Seitz <keiths@redhat.com>
Wed, 16 Apr 2014 21:12:22 +0000 (14:12 -0700)
commitfe28be73c7c22cc6eb1c3573f1be65c75e37d9b7
tree001827e9b242fb0c53b5fa54dbb10aa4ee5a3ac8
parent8056826a68e7cb370425c56703a52af98fa159fe
PR c++/16597

If lookup_symbol_file tries to locate a member variable with NULL name:

      /* A simple lookup failed.  Check if the symbol was defined in
         a base class.  */

      cleanup = make_cleanup (null_cleanup, NULL);

      /* Find the name of the class and the name of the method,
         variable, etc.  */
      prefix_len = cp_entire_prefix_len (name);

      /* If no prefix was found, search "this".  */
      if (prefix_len == 0)
        {
          struct type *type;
          struct symbol *this;

         this = lookup_language_this (language_def (language_cplus), block);
          if (this == NULL)
            {
              do_cleanups (cleanup);
              return NULL;
            }

          type = check_typedef (TYPE_TARGET_TYPE (SYMBOL_TYPE (this)));
          klass = xstrdup (TYPE_NAME (type));
          nested = xstrdup (name);
        }

TYPE_NAME (type) is NULL, so xstrdup (NULL) and boom!

This can happen, e.g., with clang++.  See testsuite/gdb.cp/namelessclass.exp
or the bugzilla report.

This patch simply adds a fencepost against this case, allowing the caller
of lookup_symbol_file to search other blocks for the right symbol.
gdb/testsuite/gdb.cp/namelessclass.S [new file with mode: 0644]
gdb/testsuite/gdb.cp/namelessclass.cc [new file with mode: 0644]
gdb/testsuite/gdb.cp/namelessclass.exp [new file with mode: 0644]