summaryrefslogtreecommitdiffstats
path: root/libdw
diff options
context:
space:
mode:
authorMark Wielaard <mark@klomp.org>2018-06-05 23:34:46 +0200
committerMark Wielaard <mark@klomp.org>2018-06-08 12:03:14 +0200
commit7ae7ec1ad75dd0689b5371c2e157165c4c7944c9 (patch)
treeb6410b975e8bad1795a6669d3085f20f0da13ac2 /libdw
parenta3b15251cdb68e225dc4e0433984784b7a6592d5 (diff)
libdw: Explicitly check we could decode diridx in dwarf_getsrclines.
It is highly unlikely dwarf_formudata fails because we setup the attribute ourselves, but better to explicitly mark diridx as bad if it does. Signed-off-by: Mark Wielaard <mark@klomp.org>
Diffstat (limited to 'libdw')
-rw-r--r--libdw/ChangeLog5
-rw-r--r--libdw/dwarf_getsrclines.c5
2 files changed, 8 insertions, 2 deletions
diff --git a/libdw/ChangeLog b/libdw/ChangeLog
index 661fa9df..21adeb7c 100644
--- a/libdw/ChangeLog
+++ b/libdw/ChangeLog
@@ -1,5 +1,10 @@
2018-06-05 Mark Wielaard <mark@klomp.org>
+ * dwarf_getsrclines.c (read_srclines): Explicitly set diridx to -1
+ in case dwarf_formudata fails.
+
+2018-06-05 Mark Wielaard <mark@klomp.org>
+
* dwarf_getaranges (dwarf_getaranges): Free new_arange if
__libdw_findcu fails.
diff --git a/libdw/dwarf_getsrclines.c b/libdw/dwarf_getsrclines.c
index 0c2efaa9..07baebcc 100644
--- a/libdw/dwarf_getsrclines.c
+++ b/libdw/dwarf_getsrclines.c
@@ -566,7 +566,7 @@ read_srclines (Dwarf *dbg,
for (unsigned int n = 0; n < nfiles; n++)
{
const char *fname = NULL;
- Dwarf_Word diridx = -1;
+ Dwarf_Word diridx = (Dwarf_Word) -1;
for (unsigned char m = 0; m < nforms; m++)
{
if (m == form_path)
@@ -581,7 +581,8 @@ read_srclines (Dwarf *dbg,
attr.code = DW_AT_decl_file; /* Close enough. */
attr.form = forms[m];
attr.valp = (void *) linep;
- dwarf_formudata (&attr, &diridx);
+ if (dwarf_formudata (&attr, &diridx) != 0)
+ diridx = (Dwarf_Word) -1;
}
size_t len = __libdw_form_val_len (&fake_cu, forms[m], linep);