diff options
author | Petr Machata <pmachata@redhat.com> | 2009-05-06 15:51:20 +0200 |
---|---|---|
committer | Petr Machata <pmachata@redhat.com> | 2009-05-06 15:51:20 +0200 |
commit | 6fb192e360f842cacb34a90c03cd0524cccc3dec (patch) | |
tree | f6d48a0be63b7a754a17c3dcee1170ba192f9948 | |
parent | a2e7612b165d83dd241225f87075fa4f58d18781 (diff) | |
download | elfutils-6fb192e360f842cacb34a90c03cd0524cccc3dec.tar.gz |
Check for presence of data before loading the offset
-rw-r--r-- | libdw/ChangeLog | 4 | ||||
-rw-r--r-- | libdw/dwarf_formudata.c | 14 |
2 files changed, 8 insertions, 10 deletions
diff --git a/libdw/ChangeLog b/libdw/ChangeLog index ec32c2d8..11ac6e73 100644 --- a/libdw/ChangeLog +++ b/libdw/ChangeLog @@ -29,10 +29,8 @@ 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> diff --git a/libdw/dwarf_formudata.c b/libdw/dwarf_formudata.c index de0489db..35288851 100644 --- a/libdw/dwarf_formudata.c +++ b/libdw/dwarf_formudata.c @@ -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)) |