This is the mail archive of the
binutils-cvs@sourceware.org
mailing list for the binutils project.
[binutils-gdb] PR22191, memory leak in dwarf2.c
- From: Alan Modra <amodra at sourceware dot org>
- To: bfd-cvs at sourceware dot org
- Date: 24 Sep 2017 11:35:14 -0000
- Subject: [binutils-gdb] PR22191, memory leak in dwarf2.c
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=a26a013f22a19e2c16729e64f40ef8a7dfcc086e
commit a26a013f22a19e2c16729e64f40ef8a7dfcc086e
Author: Alan Modra <amodra@gmail.com>
Date: Sun Sep 24 17:10:14 2017 +0930
PR22191, memory leak in dwarf2.c
table->sequences is a linked list before it is replaced by a bfd_alloc
array in sort_line_sequences.
PR 22191
* dwarf2.c (decode_line_info): Properly free line sequences on error.
Diff:
---
bfd/ChangeLog | 5 +++++
bfd/dwarf2.c | 8 ++++++--
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 450217a..c465462 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,5 +1,10 @@
2017-09-24 Alan Modra <amodra@gmail.com>
+ PR 22191
+ * dwarf2.c (decode_line_info): Properly free line sequences on error.
+
+2017-09-24 Alan Modra <amodra@gmail.com>
+
PR 22187
* dwarf2.c (find_abstract_instance_name): Add orig_info_ptr and
pname param. Return status. Make name const. Don't abort,
diff --git a/bfd/dwarf2.c b/bfd/dwarf2.c
index ec4c311..1566cd8 100644
--- a/bfd/dwarf2.c
+++ b/bfd/dwarf2.c
@@ -2476,8 +2476,12 @@ decode_line_info (struct comp_unit *unit, struct dwarf2_debug *stash)
return table;
fail:
- if (table->sequences != NULL)
- free (table->sequences);
+ while (table->sequences != NULL)
+ {
+ struct line_sequence* seq = table->sequences;
+ table->sequences = table->sequences->prev_sequence;
+ free (seq);
+ }
if (table->files != NULL)
free (table->files);
if (table->dirs != NULL)