PR22191, memory leak in dwarf2.c
authorAlan Modra <amodra@gmail.com>
Sun, 24 Sep 2017 07:40:14 +0000 (17:10 +0930)
committerAlan Modra <amodra@gmail.com>
Sun, 24 Sep 2017 11:31:30 +0000 (21:01 +0930)
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.

bfd/ChangeLog
bfd/dwarf2.c

index 450217a666cc645b186cde9362dcf3fb4699c5bc..c465462bcaf3981b90cb3fcbefc0716a290c9b5f 100644 (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
index ec4c311ec7b0b68d7186c22a708ce7ad7a8a1b9f..1566cd84b04e6243c1b751e92d140410bfca7151 100644 (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)
This page took 0.02781 seconds and 4 git commands to generate.