Skip to content

Commit 4f57c99

Browse files
libbacktrace: don't special case file 0
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
1 parent 59473f7 commit 4f57c99

File tree

1 file changed

+14
-25
lines changed

1 file changed

+14
-25
lines changed

dwarf.c

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3190,20 +3190,15 @@ read_line_program (struct backtrace_state *state, struct dwarf_data *ddata,
31903190
uint64_t fileno;
31913191

31923192
fileno = read_uleb128 (line_buf);
3193-
if (fileno == 0)
3194-
filename = "";
3195-
else
3193+
if (fileno >= hdr->filenames_count)
31963194
{
3197-
if (fileno >= hdr->filenames_count)
3198-
{
3199-
dwarf_buf_error (line_buf,
3200-
("invalid file number in "
3201-
"line number program"),
3202-
0);
3203-
return 0;
3204-
}
3205-
filename = hdr->filenames[fileno];
3195+
dwarf_buf_error (line_buf,
3196+
("invalid file number in "
3197+
"line number program"),
3198+
0);
3199+
return 0;
32063200
}
3201+
filename = hdr->filenames[fileno];
32073202
}
32083203
break;
32093204
case DW_LNS_set_column:
@@ -3631,21 +3626,15 @@ read_function_entry (struct backtrace_state *state, struct dwarf_data *ddata,
36313626
case DW_AT_call_file:
36323627
if (val.encoding == ATTR_VAL_UINT)
36333628
{
3634-
if (val.u.uint == 0)
3635-
function->caller_filename = "";
3636-
else
3629+
if (val.u.uint >= lhdr->filenames_count)
36373630
{
3638-
if (val.u.uint >= lhdr->filenames_count)
3639-
{
3640-
dwarf_buf_error (unit_buf,
3641-
("invalid file number in "
3642-
"DW_AT_call_file attribute"),
3643-
0);
3644-
return 0;
3645-
}
3646-
function->caller_filename =
3647-
lhdr->filenames[val.u.uint];
3631+
dwarf_buf_error (unit_buf,
3632+
("invalid file number in "
3633+
"DW_AT_call_file attribute"),
3634+
0);
3635+
return 0;
36483636
}
3637+
function->caller_filename = lhdr->filenames[val.u.uint];
36493638
}
36503639
break;
36513640

0 commit comments

Comments
 (0)