summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry V. Levin <ldv@altlinux.org>2015-11-16 18:11:23 +0300
committerMark Wielaard <mjw@redhat.com>2015-11-16 17:11:34 +0100
commitb47fb2366f2ac3015d7cf9ae3938392196609831 (patch)
treed5b7b4dcc527b67157c79eb6ac9e3c4a6c815166
parentf8443bd09f8a8d3d84a63e5ce206a218e57dff7a (diff)
downloadelfutils-b47fb2366f2ac3015d7cf9ae3938392196609831.tar.gz
libdw: initialize state early in read_srclines
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>
-rw-r--r--libdw/ChangeLog4
-rw-r--r--libdw/dwarf_getsrclines.c39
2 files changed, 24 insertions, 19 deletions
diff --git a/libdw/ChangeLog b/libdw/ChangeLog
index b344d92c..5218145e 100644
--- a/libdw/ChangeLog
+++ b/libdw/ChangeLog
@@ -1,3 +1,7 @@
+2015-10-16 Dmitry V. Levin <ldv@altlinux.org>
+
+ * dwarf_getsrclines.c (read_srclines): Initialize state early.
+
2015-10-13 Chih-Hung Hsieh <chh@google.com>
* dwarf_getsrclines.c (read_srclines): Move nested functions
diff --git a/libdw/dwarf_getsrclines.c b/libdw/dwarf_getsrclines.c
index 03bdc8f3..dd1b3c1f 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). */