libdw: Explicitly check we could decode diridx in dwarf_getsrclines.
authorMark Wielaard <mark@klomp.org>
Tue, 5 Jun 2018 21:34:46 +0000 (23:34 +0200)
committerMark Wielaard <mark@klomp.org>
Fri, 8 Jun 2018 10:03:14 +0000 (12:03 +0200)
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>
libdw/ChangeLog
libdw/dwarf_getsrclines.c

index 661fa9d..21adeb7 100644 (file)
@@ -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.
 
index 0c2efaa..07baebc 100644 (file)
@@ -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);