libdwfl: Fix memory leak in cache_sections.
authorMark Wielaard <mjw@redhat.com>
Sat, 6 Jun 2015 20:49:34 +0000 (22:49 +0200)
committerMark Wielaard <mjw@redhat.com>
Tue, 9 Jun 2015 20:53:05 +0000 (22:53 +0200)
commit be1778 libdwfl: Fix possible unbounded stack usage in cache_sections.
introduced a memory leak. The refs pointers were copied to the sortrefs
array but never freed. Only the array was freed. Also free the elements.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
libdwfl/ChangeLog
libdwfl/derelocate.c

index 0daf893..956ac9f 100644 (file)
@@ -1,3 +1,7 @@
+2015-06-06  Mark Wielaard  <mjw@redhat.com>
+
+       * derelocate.c (cache_sections): Free sortrefs.
+
 2015-06-05  Mark Wielaard  <mjw@redhat.com>
 
        * dwfl_segment_report_module.c (dwfl_segment_report_module):
index 48f8193..439a24e 100644 (file)
@@ -177,6 +177,7 @@ cache_sections (Dwfl_Module *mod)
       mod->reloc_info->refs[i].relocs = sortrefs[i]->relocs;
       mod->reloc_info->refs[i].start = sortrefs[i]->start;
       mod->reloc_info->refs[i].end = sortrefs[i]->end;
+      free (sortrefs[i]);
     }
 
   free (sortrefs);