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.
This commit is contained in:
Alan Modra 2017-09-24 17:10:14 +09:30
parent 52a93b95ec
commit a26a013f22
2 changed files with 11 additions and 2 deletions

View File

@ -1,3 +1,8 @@
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

View File

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