public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] libdw: dwarf_get_units should handle existing failure to open Dwarf.
@ 2018-06-08 18:45 Mark Wielaard
  2018-06-11  6:37 ` Mark Wielaard
  0 siblings, 1 reply; 2+ messages in thread
From: Mark Wielaard @ 2018-06-08 18:45 UTC (permalink / raw)
  To: elfutils-devel; +Cc: Mark Wielaard

The other dwarf unit/cu iterators handle a NULL Dwarf handle as an
existing error and return NULL. Don't crash.

Signed-off-by: Mark Wielaard <mark@klomp.org>
---
 libdw/ChangeLog         | 5 +++++
 libdw/dwarf_get_units.c | 4 ++++
 2 files changed, 9 insertions(+)

diff --git a/libdw/ChangeLog b/libdw/ChangeLog
index 23e11b9..21cb03c 100644
--- a/libdw/ChangeLog
+++ b/libdw/ChangeLog
@@ -1,5 +1,10 @@
 2018-06-08  Mark Wielaard  <mark@klomp.org>
 
+	* dwarf_get_units.c (dwarf_get_units): Handle existing error, no
+	dwarf.
+
+2018-06-08  Mark Wielaard  <mark@klomp.org>
+
 	* dwarf_getlocation.c (store_implicit_value): Return error when
 	seeing bad DWARF or when tsearch runs out of memory.
 	(__libdw_intern_expression): Report error when store_implicit_value
diff --git a/libdw/dwarf_get_units.c b/libdw/dwarf_get_units.c
index aece17e..6215bf4 100644
--- a/libdw/dwarf_get_units.c
+++ b/libdw/dwarf_get_units.c
@@ -40,6 +40,10 @@ dwarf_get_units (Dwarf *dwarf, Dwarf_CU *cu, Dwarf_CU **next_cu,
 		 Dwarf_Half *version, uint8_t *unit_type,
 		 Dwarf_Die *cudie, Dwarf_Die *subdie)
 {
+  /* Handle existing error.  */
+  if (dwarf == NULL)
+    return -1;
+
   Dwarf_Off off;
   bool v4type;
   if (cu == NULL)
-- 
1.8.3.1

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

* Re: [PATCH] libdw: dwarf_get_units should handle existing failure to open Dwarf.
  2018-06-08 18:45 [PATCH] libdw: dwarf_get_units should handle existing failure to open Dwarf Mark Wielaard
@ 2018-06-11  6:37 ` Mark Wielaard
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Wielaard @ 2018-06-11  6:37 UTC (permalink / raw)
  To: elfutils-devel

On Fri, 2018-06-08 at 20:45 +0200, Mark Wielaard wrote:
> The other dwarf unit/cu iterators handle a NULL Dwarf handle as an
> existing error and return NULL. Don't crash.

Pushed to master.

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

end of thread, other threads:[~2018-06-11  6:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-08 18:45 [PATCH] libdw: dwarf_get_units should handle existing failure to open Dwarf Mark Wielaard
2018-06-11  6:37 ` 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).