public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
* Re: [PATCH] libdw: initialize state early in read_srclines
@ 2015-11-16 16:13 Mark Wielaard
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Wielaard @ 2015-11-16 16:13 UTC (permalink / raw)
  To: elfutils-devel

[-- Attachment #1: Type: text/plain, Size: 452 bytes --]

On Mon, 2015-11-16 at 18:11 +0300, Dmitry V. Levin wrote:
> Starting with commit f8443bd09f8a8d3d84a63e5ce206a218e57dff7a,
> we might jump to "out" on error before initialization of "state".
> Initialize "state" early to fix this issue.

Right, and "out" cleans up using some of the "state" following the
linelist pointer. So we better make sure that is always setup correctly.

Added a ChangeLog entry and applied to master.

Thanks,

Mark

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

* [PATCH] libdw: initialize state early in read_srclines
@ 2015-11-16 15:11 Dmitry V. Levin
  0 siblings, 0 replies; 2+ messages in thread
From: Dmitry V. Levin @ 2015-11-16 15:11 UTC (permalink / raw)
  To: elfutils-devel

[-- Attachment #1: Type: text/plain, Size: 2140 bytes --]

Starting with commit f8443bd09f8a8d3d84a63e5ce206a218e57dff7a,
we might jump to "out" on error before initialization of "state".
Initialize "state" early to fix this issue.

Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
---
 libdw/dwarf_getsrclines.c | 39 ++++++++++++++++++++-------------------
 1 file changed, 20 insertions(+), 19 deletions(-)

diff --git a/libdw/dwarf_getsrclines.c b/libdw/dwarf_getsrclines.c
index 03bdc8f..dd1b3c1 100644
--- a/libdw/dwarf_getsrclines.c
+++ b/libdw/dwarf_getsrclines.c
@@ -185,6 +185,25 @@ read_srclines (Dwarf *dbg,
   struct dirlist dirstack[MAX_STACK_DIRS];
   struct dirlist *dirarray = dirstack;
 
+  /* We are about to process the statement program.  Initialize the
+     state machine registers (see 6.2.2 in the v2.1 specification).  */
+  struct line_state state =
+    {
+      .linelist = NULL,
+      .nlinelist = 0,
+      .addr = 0,
+      .op_index = 0,
+      .file = 1,
+      /* We only store int but want to check for overflow (see SET above).  */
+      .line = 1,
+      .column = 0,
+      .basic_block = false,
+      .prologue_end = false,
+      .epilogue_begin = false,
+      .isa = 0,
+      .discriminator = 0
+    };
+
   if (unlikely (linep + 4 > lineendp))
     {
     invalid_data:
@@ -387,25 +406,7 @@ read_srclines (Dwarf *dbg,
       goto out;
     }
 
-  /* We are about to process the statement program.  Initialize the
-     state machine registers (see 6.2.2 in the v2.1 specification).  */
-  struct line_state state =
-    {
-      .linelist = NULL,
-      .nlinelist = 0,
-      .addr = 0,
-      .op_index = 0,
-      .file = 1,
-      /* We only store int but want to check for overflow (see SET above).  */
-      .line = 1,
-      .column = 0,
-      .is_stmt = default_is_stmt,
-      .basic_block = false,
-      .prologue_end = false,
-      .epilogue_begin = false,
-      .isa = 0,
-      .discriminator = 0
-    };
+  state.is_stmt = default_is_stmt;
 
   /* Apply the "operation advance" from a special opcode or
      DW_LNS_advance_pc (as per DWARF4 6.2.5.1).  */

-- 
ldv

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

end of thread, other threads:[~2015-11-16 16:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-16 16:13 [PATCH] libdw: initialize state early in read_srclines Mark Wielaard
  -- strict thread matches above, loose matches on Subject: below --
2015-11-16 15:11 Dmitry V. Levin

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).