From: Petr Machata Date: Wed, 6 May 2009 13:51:20 +0000 (+0200) Subject: Check for presence of data before loading the offset X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6fb192e360f842cacb34a90c03cd0524cccc3dec;p=thirdparty%2Felfutils.git Check for presence of data before loading the offset --- diff --git a/libdw/ChangeLog b/libdw/ChangeLog index ec32c2d81..11ac6e735 100644 --- a/libdw/ChangeLog +++ b/libdw/ChangeLog @@ -29,10 +29,8 @@ 2009-04-23 Petr Machata * 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 diff --git a/libdw/dwarf_formudata.c b/libdw/dwarf_formudata.c index de0489db7..352888513 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))