public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] libdw: dwarf_aggregate_size should not don't peel the given DIE.
@ 2017-12-12  9:51 Mark Wielaard
  2017-12-15 18:42 ` Mark Wielaard
  0 siblings, 1 reply; 2+ messages in thread
From: Mark Wielaard @ 2017-12-12  9:51 UTC (permalink / raw)
  To: elfutils-devel; +Cc: Mark Wielaard

Reserve memory for a new DIE first. The caller might not care, but it
isn't really nice to change the DIE the caller gave us.

See also https://sourceware.org/bugzilla/show_bug.cgi?id=22546#c5

Signed-off-by: Mark Wielaard <mark@klomp.org>
---
 libdw/ChangeLog              | 5 +++++
 libdw/dwarf_aggregate_size.c | 6 +++---
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/libdw/ChangeLog b/libdw/ChangeLog
index 2a6d711..350230e 100644
--- a/libdw/ChangeLog
+++ b/libdw/ChangeLog
@@ -1,3 +1,8 @@
+2017-12-12  Mark Wielaard  <mark@klomp.org>
+
+	* dwarf_aggregate_size.c (dwarf_aggregate_size): Don't peel the
+	given DIE. Reserve memory for a new DIE first.
+
 2017-12-11  Dima Kogan  <dima@secretsauce.net>
 
 	* dwarf_aggregate_size.c (array_size): Handle multi-dimensional
diff --git a/libdw/dwarf_aggregate_size.c b/libdw/dwarf_aggregate_size.c
index 3010c0a..6e50185 100644
--- a/libdw/dwarf_aggregate_size.c
+++ b/libdw/dwarf_aggregate_size.c
@@ -199,12 +199,12 @@ aggregate_size (Dwarf_Die *die, Dwarf_Word *size, Dwarf_Die *type_mem)
 int
 dwarf_aggregate_size (Dwarf_Die *die, Dwarf_Word *size)
 {
-  Dwarf_Die type_mem;
+  Dwarf_Die die_mem, type_mem;
 
-  if (INTUSE (dwarf_peel_type) (die, die) != 0)
+  if (INTUSE (dwarf_peel_type) (die, &die_mem) != 0)
     return -1;
 
-  return aggregate_size (die, size, &type_mem);
+  return aggregate_size (&die_mem, size, &type_mem);
 }
 INTDEF (dwarf_aggregate_size)
 OLD_VERSION (dwarf_aggregate_size, ELFUTILS_0.144)
-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] libdw: dwarf_aggregate_size should not don't peel the given DIE.
  2017-12-12  9:51 [PATCH] libdw: dwarf_aggregate_size should not don't peel the given DIE Mark Wielaard
@ 2017-12-15 18:42 ` Mark Wielaard
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Wielaard @ 2017-12-15 18:42 UTC (permalink / raw)
  To: elfutils-devel

On Tue, 2017-12-12 at 10:51 +0100, Mark Wielaard wrote:
> Reserve memory for a new DIE first. The caller might not care, but it
> isn't really nice to change the DIE the caller gave us.
> 
> See also https://sourceware.org/bugzilla/show_bug.cgi?id=22546#c5

Pushed to master.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-12-15 18:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-12  9:51 [PATCH] libdw: dwarf_aggregate_size should not don't peel the given DIE Mark Wielaard
2017-12-15 18:42 ` Mark Wielaard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).