diff options
author | Petr Machata <pmachata@redhat.com> | 2009-05-07 21:02:33 +0200 |
---|---|---|
committer | Petr Machata <pmachata@redhat.com> | 2009-05-07 21:02:33 +0200 |
commit | f3df61f7514b4c217b4bf16a62c93493bb1fef56 (patch) | |
tree | 34d6a560d3d148217b27a7f7d9cc46389889937c /libdw/dwarf_getmacros.c | |
parent | d24c7bfeca98d0142bb46a44e248f57675a8c0c3 (diff) | |
download | elfutils-f3df61f7514b4c217b4bf16a62c93493bb1fef56.tar.gz |
Fix dwarf_getmacros so that it passes newly-added test
Diffstat (limited to 'libdw/dwarf_getmacros.c')
-rw-r--r-- | libdw/dwarf_getmacros.c | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/libdw/dwarf_getmacros.c b/libdw/dwarf_getmacros.c index 743ade3b..5f24d37b 100644 --- a/libdw/dwarf_getmacros.c +++ b/libdw/dwarf_getmacros.c @@ -75,17 +75,20 @@ dwarf_getmacros (die, callback, arg, offset) if (INTUSE(dwarf_formudata) (&attr, &macoff) != 0) return -1; - const unsigned char *readp - = die->cu->dbg->sectiondata[IDX_debug_macinfo]->d_buf + offset; - const unsigned char *readendp - = readp + die->cu->dbg->sectiondata[IDX_debug_macinfo]->d_size; + Elf_Data *d = die->cu->dbg->sectiondata[IDX_debug_macinfo]; + if (unlikely (d == NULL) || unlikely (d->d_buf == NULL)) + { + __libdw_seterrno (DWARF_E_NO_ENTRY); + return -1; + } + + const unsigned char *macdata = d->d_buf + macoff; + const unsigned char *readp = macdata + offset; + const unsigned char *readendp = d->d_buf + d->d_size; if (readp == readendp) return 0; - if (*readp != DW_MACINFO_start_file) - goto invalid; - while (readp < readendp) { unsigned int opcode = *readp++; @@ -142,9 +145,7 @@ dwarf_getmacros (die, callback, arg, offset) mac.param2.s = str; if (callback (&mac, arg) != DWARF_CB_OK) - return (readp - - ((unsigned char *) die->cu->dbg->sectiondata[IDX_debug_macinfo]->d_buf - + offset)); + return readp - macdata; } /* If we come here the termination of the data for the CU is not |