From: Alan Modra Date: Sun, 24 Sep 2017 07:40:14 +0000 (+0930) Subject: PR22191, memory leak in dwarf2.c X-Git-Url: http://git.efficios.com/?a=commitdiff_plain;h=a26a013f22a19e2c16729e64f40ef8a7dfcc086e;p=deliverable%2Fbinutils-gdb.git 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 --git a/bfd/ChangeLog b/bfd/ChangeLog index 450217a666..c465462bca 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,8 @@ +2017-09-24 Alan Modra + + PR 22191 + * dwarf2.c (decode_line_info): Properly free line sequences on error. + 2017-09-24 Alan Modra PR 22187 diff --git a/bfd/dwarf2.c b/bfd/dwarf2.c index ec4c311ec7..1566cd84b0 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)