aboutsummaryrefslogtreecommitdiff
path: root/bfd/dwarf2.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2017-09-24 17:10:14 +0930
committerAlan Modra <amodra@gmail.com>2017-09-24 21:01:30 +0930
commita26a013f22a19e2c16729e64f40ef8a7dfcc086e (patch)
treee34c6fbf1e01b3d26e1b6409fc1a5a090a033064 /bfd/dwarf2.c
parent52a93b95ec0771c97e26f0bb28630a271a667bd2 (diff)
downloadgdb-a26a013f22a19e2c16729e64f40ef8a7dfcc086e.zip
gdb-a26a013f22a19e2c16729e64f40ef8a7dfcc086e.tar.gz
gdb-a26a013f22a19e2c16729e64f40ef8a7dfcc086e.tar.bz2
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.
Diffstat (limited to 'bfd/dwarf2.c')
-rw-r--r--bfd/dwarf2.c8
1 files changed, 6 insertions, 2 deletions
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)