]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
Check for presence of data before loading the offset
authorPetr Machata <pmachata@redhat.com>
Wed, 6 May 2009 13:51:20 +0000 (15:51 +0200)
committerPetr Machata <pmachata@redhat.com>
Wed, 6 May 2009 13:51:20 +0000 (15:51 +0200)
libdw/ChangeLog
libdw/dwarf_formudata.c

index ec32c2d81b4bd8e118b9ea2a96fd63cf659c34ce..11ac6e73581d8f6d0fce7976b6a87edfc55a1e4b 100644 (file)
 2009-04-23  Petr Machata  <pmachata@redhat.com>
 
        * libdwP.h (__libdw_read_addr_inc, __libdw_read_off_inc,
-       __libdw_read_addr, __libdw_read_off): Declare four new internal
+       __libdw_read_addr, __libdw_read_off): Add four new internal
        functions.
-       * dwarf_readhooks.c: New file, implements the above.
-       * Makefile.am (libdw_a_SOURCES): Add the new file
 
 2009-04-15  Roland McGrath  <roland@redhat.com>
 
index de0489db7d38afbde0cd02d71940ed3c39dc0cea..352888513b0080939eae34ac8f1153a78b78af2f 100644 (file)
@@ -63,6 +63,13 @@ __libdw_formptr (Dwarf_Attribute *attr, int sec_index,
   if (attr == NULL)
     return NULL;
 
+  const Elf_Data *d = attr->cu->dbg->sectiondata[sec_index];
+  if (unlikely (d == NULL))
+    {
+      __libdw_seterrno (err_nodata);
+      return NULL;
+    }
+
   Dwarf_Word offset;
   switch (attr->form)
     {
@@ -79,13 +86,6 @@ __libdw_formptr (Dwarf_Attribute *attr, int sec_index,
        return NULL;
     };
 
-  const Elf_Data *d = attr->cu->dbg->sectiondata[sec_index];
-  if (unlikely (d == NULL))
-    {
-      __libdw_seterrno (err_nodata);
-      return NULL;
-    }
-
   unsigned char *readp = d->d_buf + offset;
   unsigned char *endp = d->d_buf + d->d_size;
   if (unlikely (readp >= endp))