PR25827, Null pointer dereferencing in scan_unit_for_symbols

PR 25827
	* dwarf2.c (scan_unit_for_symbols): Wrap overlong lines.  Don't
	strdup(0).
This commit is contained in:
Alan Modra 2020-04-16 17:49:38 +09:30
parent c54a9b5669
commit aec72fda3b
2 changed files with 13 additions and 5 deletions

View file

@ -1,3 +1,9 @@
2020-04-16 Alan Modra <amodra@gmail.com>
PR 25827
* dwarf2.c (scan_unit_for_symbols): Wrap overlong lines. Don't
strdup(0).
2020-04-15 Fangrui Song <maskray@google.com> 2020-04-15 Fangrui Song <maskray@google.com>
PR binutils/24613 PR binutils/24613

View file

@ -3379,18 +3379,20 @@ scan_unit_for_symbols (struct comp_unit *unit)
{ {
struct varinfo * spec_var; struct varinfo * spec_var;
spec_var = lookup_var_by_offset (attr.u.val, unit->variable_table); spec_var = lookup_var_by_offset (attr.u.val,
unit->variable_table);
if (spec_var == NULL) if (spec_var == NULL)
{ {
_bfd_error_handler _bfd_error_handler (_("DWARF error: could not find "
(_("DWARF error: could not find variable specification at offset %lx"), "variable specification "
(unsigned long) attr.u.val); "at offset %lx"),
(unsigned long) attr.u.val);
break; break;
} }
if (var->name == NULL) if (var->name == NULL)
var->name = spec_var->name; var->name = spec_var->name;
if (var->file == NULL) if (var->file == NULL && spec_var->file != NULL)
var->file = strdup (spec_var->file); var->file = strdup (spec_var->file);
if (var->line == 0) if (var->line == 0)
var->line = spec_var->line; var->line = spec_var->line;