From 6fb3451de3ba29b628be6e30a01ef104156d4733 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Fri, 28 May 2010 20:28:04 -0700 Subject: [PATCH] dwarf_getlocation crash on NULL attribute. A recent change added code in front of the attr_ok check. This breaks existing code that assumes it can pass NULL to the ATTR parameter. Move the attr_ok check back to the front. --- libdw/ChangeLog | 7 ++++++- libdw/dwarf_getlocation.c | 6 +++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/libdw/ChangeLog b/libdw/ChangeLog index 9f876523c..0cc976943 100644 --- a/libdw/ChangeLog +++ b/libdw/ChangeLog @@ -1,3 +1,8 @@ +2010-05-28 Ulrich Drepper + + * dwarf_getlocation.c (dwarf_getlocation): Move attr_ok call back to + the front. + 2010-05-27 Roland McGrath * dwarf.h: Add DW_AT_enum_class, DW_AT_linkage_name, @@ -1329,4 +1334,4 @@ 2003-08-11 Ulrich Drepper - * Moved to CVS archive. + * Moved to CVS archive. diff --git a/libdw/dwarf_getlocation.c b/libdw/dwarf_getlocation.c index ede8c3c9d..c89488b30 100644 --- a/libdw/dwarf_getlocation.c +++ b/libdw/dwarf_getlocation.c @@ -541,13 +541,13 @@ dwarf_getlocation (attr, llbuf, listlen) Dwarf_Op **llbuf; size_t *listlen; { + if (! attr_ok (attr)) + return -1; + int result = check_constant_offset (attr, llbuf, listlen); if (result != 1) return result; - if (! attr_ok (attr)) - return -1; - /* If it has a block form, it's a single location expression. */ Dwarf_Block block; if (INTUSE(dwarf_formblock) (attr, &block) != 0) -- 2.47.2