summaryrefslogtreecommitdiff
path: root/libdw/dwarf_ranges.c
diff options
context:
space:
mode:
authorMark Wielaard <mark@klomp.org>2018-05-24 15:20:25 +0200
committerMark Wielaard <mark@klomp.org>2018-05-24 15:20:25 +0200
commitc2d14cc492aa7fd28740d5789fede64ce81a063b (patch)
tree8dc6ce6af3e6720848debfabb4cde5ad2e1361b4 /libdw/dwarf_ranges.c
parent144b73c49acf3ed894e4635aedb9b0d1208ade2e (diff)
downloadelfutils-c2d14cc492aa7fd28740d5789fede64ce81a063b.tar.gz
libdw: Initialize ranges_base, add invalid DWARF test and fix expected output.
We never initialized the CU ranges_base, which meant we didn't actually calculate it correctly. This caused bad ranges on some DIEs. The expected output in the testcase was wrong. We also crashed on invalid dwarf. Signed-off-by: Mark Wielaard <mark@klomp.org>
Diffstat (limited to 'libdw/dwarf_ranges.c')
-rw-r--r--libdw/dwarf_ranges.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/libdw/dwarf_ranges.c b/libdw/dwarf_ranges.c
index b0450cf3..52a61eea 100644
--- a/libdw/dwarf_ranges.c
+++ b/libdw/dwarf_ranges.c
@@ -123,6 +123,12 @@ dwarf_ranges (Dwarf_Die *die, ptrdiff_t offset, Dwarf_Addr *basep,
/* We have to look for a noncontiguous range. */
size_t secidx = IDX_debug_ranges;
Dwarf_CU *cu = die->cu;
+ if (cu == NULL)
+ {
+ __libdw_seterrno (DWARF_E_INVALID_DWARF);
+ return -1;
+ }
+
const Elf_Data *d = cu->dbg->sectiondata[secidx];
if (d == NULL && cu->unit_type == DW_UT_split_compile)
{