Author: emaste
Date: Wed Feb 25 21:43:09 2015
New Revision: 279298
URL: https://svnweb.freebsd.org/changeset/base/279298

Log:
  nm: avoid crash in print_lineno if func->name is NULL
  
  This can occur when DW_AT_specification is used to refer to another DIE
  that provides the actual DW_AT_name string. For example:
  
  < 3><0x00000086> DW_TAG_subprogram
                     DW_AT_name              PrettyStackTraceEntry
  ...
  < 1><0x00002cf4> DW_TAG_subprogram
                     DW_AT_specification     <0x00000086>
  
  We will need to add support for DW_AT_specification, but in the interim
  we should not segfault.
  
  Obtained from:        Elftoolchain (r3170)
  Sponsored by: The FreeBSD Foundation

Modified:
  head/contrib/elftoolchain/nm/nm.c

Modified: head/contrib/elftoolchain/nm/nm.c
==============================================================================
--- head/contrib/elftoolchain/nm/nm.c   Wed Feb 25 21:10:03 2015        
(r279297)
+++ head/contrib/elftoolchain/nm/nm.c   Wed Feb 25 21:43:09 2015        
(r279298)
@@ -1525,7 +1525,8 @@ print_lineno(struct sym_entry *ep, struc
        /* For function symbol, search the function line information list.  */
        if ((ep->sym->st_info & 0xf) == STT_FUNC && func_info != NULL) {
                SLIST_FOREACH(func, func_info, entries) {
-                       if (!strcmp(ep->name, func->name) &&
+                       if (func->name != NULL &&
+                           !strcmp(ep->name, func->name) &&
                            ep->sym->st_value >= func->lowpc &&
                            ep->sym->st_value < func->highpc) {
                                printf("\t%s:%" PRIu64, func->file, func->line);
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to