diff options
Diffstat (limited to 'libdw/dwarf_getaranges.c')
| -rw-r--r-- | libdw/dwarf_getaranges.c | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/libdw/dwarf_getaranges.c b/libdw/dwarf_getaranges.c index 4252746e..bff9c860 100644 --- a/libdw/dwarf_getaranges.c +++ b/libdw/dwarf_getaranges.c @@ -1,5 +1,5 @@ /* Return list address ranges. - Copyright (C) 2000-2010 Red Hat, Inc. + Copyright (C) 2000-2010, 2016, 2017 Red Hat, Inc. This file is part of elfutils. Written by Ulrich Drepper <[email protected]>, 2000. @@ -195,16 +195,15 @@ dwarf_getaranges (Dwarf *dbg, Dwarf_Aranges **aranges, size_t *naranges) new_arange->arange.length = range_length; /* We store the actual CU DIE offset, not the CU header offset. */ - const char *cu_header = (dbg->sectiondata[IDX_debug_info]->d_buf - + offset); - unsigned int offset_size; - if (read_4ubyte_unaligned_noncvt (cu_header) == DWARF3_LENGTH_64_BIT) - offset_size = 8; - else - offset_size = 4; - new_arange->arange.offset = DIE_OFFSET_FROM_CU_OFFSET (offset, - offset_size, - false); + Dwarf_CU *cu = __libdw_findcu (dbg, offset, false); + if (unlikely (cu == NULL)) + { + /* We haven't gotten a chance to link in the new_arange + into the arangelist, don't leak it. */ + free (new_arange); + goto fail; + } + new_arange->arange.offset = __libdw_first_die_off_from_cu (cu); new_arange->next = arangelist; arangelist = new_arange; |
