Skip to content

Commit

Permalink
libbacktrace: don't special case file 0
Browse files Browse the repository at this point in the history
It's no longer necessary as file 0 is now set up in all cases.

	* dwarf.c (read_line_program): Don't special case file 0.
	(read_function_entry): Likewise.

Fixes #69
  • Loading branch information
ianlancetaylor committed Mar 3, 2021
1 parent 59473f7 commit 4f57c99
Showing 1 changed file with 14 additions and 25 deletions.
39 changes: 14 additions & 25 deletions dwarf.c
Expand Up @@ -3190,20 +3190,15 @@ read_line_program (struct backtrace_state *state, struct dwarf_data *ddata,
uint64_t fileno;

fileno = read_uleb128 (line_buf);
if (fileno == 0)
filename = "";
else
if (fileno >= hdr->filenames_count)
{
if (fileno >= hdr->filenames_count)
{
dwarf_buf_error (line_buf,
("invalid file number in "
"line number program"),
0);
return 0;
}
filename = hdr->filenames[fileno];
dwarf_buf_error (line_buf,
("invalid file number in "
"line number program"),
0);
return 0;
}
filename = hdr->filenames[fileno];
}
break;
case DW_LNS_set_column:
Expand Down Expand Up @@ -3631,21 +3626,15 @@ read_function_entry (struct backtrace_state *state, struct dwarf_data *ddata,
case DW_AT_call_file:
if (val.encoding == ATTR_VAL_UINT)
{
if (val.u.uint == 0)
function->caller_filename = "";
else
if (val.u.uint >= lhdr->filenames_count)
{
if (val.u.uint >= lhdr->filenames_count)
{
dwarf_buf_error (unit_buf,
("invalid file number in "
"DW_AT_call_file attribute"),
0);
return 0;
}
function->caller_filename =
lhdr->filenames[val.u.uint];
dwarf_buf_error (unit_buf,
("invalid file number in "
"DW_AT_call_file attribute"),
0);
return 0;
}
function->caller_filename = lhdr->filenames[val.u.uint];
}
break;

Expand Down

0 comments on commit 4f57c99

Please sign in to comment.