If the buffer isn't released after getting a valid build-id from the
memory_callback the first run-unstrip-n.sh testcase will fail on systems
where there is a matching librt.so file for which dwfl_addrsegment returns
a valid segment index in the Dwfl (but where the build-id doesn't match).

Signed-off-by: Mark Wielaard <[email protected]>
---
 libdwfl/ChangeLog  |  5 +++++
 libdwfl/link_map.c | 13 ++++++++-----
 2 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog
index 9ee0ab1..e000413 100644
--- a/libdwfl/ChangeLog
+++ b/libdwfl/ChangeLog
@@ -1,3 +1,8 @@
+2013-06-05  Mark Wielaard  <[email protected]>
+
+       * link_map.c (report_r_debug): Always call release_buffer after
+       memory_callback succeeded reading build_id.
+
 2013-05-30  Jan Kratochvil  <[email protected]>
 
        * argp-std.c (parse_opt) <ARGP_KEY_SUCCESS> <opt->core> <opt->e>: Set
diff --git a/libdwfl/link_map.c b/libdwfl/link_map.c
index e752a5d..6d64b80 100644
--- a/libdwfl/link_map.c
+++ b/libdwfl/link_map.c
@@ -395,12 +395,15 @@ report_r_debug (uint_fast8_t elfclass, uint_fast8_t 
elfdata,
                      if (! (*memory_callback) (dwfl, segndx,
                                                &buffer, &buffer_available,
                                                build_id_vaddr, build_id_len,
-                                               memory_callback_arg)
-                         || memcmp (build_id_bits, buffer, build_id_len) != 0)
+                                               memory_callback_arg))
+                       valid = false;
+                     else
                        {
-                         /* File has valid build-id which cannot be verified
-                            in memory.  */
-                         valid = false;
+                         if (memcmp (build_id_bits, buffer, build_id_len) != 0)
+                           /* File has valid build-id which cannot be verified
+                              in memory.  */
+                             valid = false;
+                         release_buffer (0);
                        }
                    }
 
-- 
1.8.1.4

_______________________________________________
elfutils-devel mailing list
[email protected]
https://lists.fedorahosted.org/mailman/listinfo/elfutils-devel

Reply via email to