public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] libdw: Enable building with -Og.
@ 2018-11-23 20:08 Mark Wielaard
  2018-11-26 10:36 ` Mark Wielaard
  0 siblings, 1 reply; 2+ messages in thread
From: Mark Wielaard @ 2018-11-23 20:08 UTC (permalink / raw)
  To: elfutils-devel; +Cc: Mark Wielaard

When building with -Og gcc is unable to see that __libdw_dieabbrev ()
will initialize what the second argument points to when no error occurs
as called by dwarf_child and dwarf_getattrs. Causing an possibly
uninitialized error. Just initialize readp/die_addr to NULL, which is
the value we would return if an error occurs anyway.

https://sourceware.org/bugzilla/show_bug.cgi?id=23914

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

diff --git a/libdw/ChangeLog b/libdw/ChangeLog
index 7caa223..44405d7 100644
--- a/libdw/ChangeLog
+++ b/libdw/ChangeLog
@@ -1,3 +1,8 @@
+2018-10-23  Mark Wielaard  <mark@klomp.org>
+
+	* dwarf_child.c (__libdw_find_attr): Initialize readp to NULL.
+	* dwarf_getattrs.c (dwarf_getattrs): Initialize die_addr to NULL.
+
 2018-10-20  Mark Wielaard  <mark@klomp.org>
 
 	* libdw.map (ELFUTILS_0.175): New section. Add dwelf_elf_begin.
diff --git a/libdw/dwarf_child.c b/libdw/dwarf_child.c
index 9446b88..2e39d83 100644
--- a/libdw/dwarf_child.c
+++ b/libdw/dwarf_child.c
@@ -43,7 +43,7 @@ internal_function
 __libdw_find_attr (Dwarf_Die *die, unsigned int search_name,
 		   unsigned int *codep, unsigned int *formp)
 {
-  const unsigned char *readp;
+  const unsigned char *readp = NULL;
 
   /* Find the abbreviation entry.  */
   Dwarf_Abbrev *abbrevp = __libdw_dieabbrev (die, &readp);
diff --git a/libdw/dwarf_getattrs.c b/libdw/dwarf_getattrs.c
index 50faf98..4ac16b1 100644
--- a/libdw/dwarf_getattrs.c
+++ b/libdw/dwarf_getattrs.c
@@ -44,7 +44,7 @@ dwarf_getattrs (Dwarf_Die *die, int (*callback) (Dwarf_Attribute *, void *),
   if (unlikely (offset == 1))
     return 1;
 
-  const unsigned char *die_addr;
+  const unsigned char *die_addr = NULL;
 
   /* Find the abbreviation entry.  */
   Dwarf_Abbrev *abbrevp = __libdw_dieabbrev (die, &die_addr);
-- 
1.8.3.1

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

* Re: [PATCH] libdw: Enable building with -Og.
  2018-11-23 20:08 [PATCH] libdw: Enable building with -Og Mark Wielaard
@ 2018-11-26 10:36 ` Mark Wielaard
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Wielaard @ 2018-11-26 10:36 UTC (permalink / raw)
  To: elfutils-devel

On Fri, 2018-11-23 at 21:08 +0100, Mark Wielaard wrote:
> When building with -Og gcc is unable to see that __libdw_dieabbrev ()
> will initialize what the second argument points to when no error
> occurs
> as called by dwarf_child and dwarf_getattrs. Causing an possibly
> uninitialized error. Just initialize readp/die_addr to NULL, which is
> the value we would return if an error occurs anyway.
> 
> https://sourceware.org/bugzilla/show_bug.cgi?id=23914

Pushed to master.

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

end of thread, other threads:[~2018-11-26 10:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-23 20:08 [PATCH] libdw: Enable building with -Og Mark Wielaard
2018-11-26 10:36 ` 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).