]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
findtextrel: Don't leak memory in process_file.
authorMark Wielaard <mjw@redhat.com>
Thu, 18 Jun 2015 21:43:39 +0000 (23:43 +0200)
committerMark Wielaard <mjw@redhat.com>
Fri, 19 Jun 2015 11:11:22 +0000 (13:11 +0200)
When a files do contain textrels we fail to release the segments searched
and valgrind will show:

 2,560 bytes in 16 blocks are definitely lost in loss record 1 of 1
    at 0x40281B5: malloc (in vgpreload_memcheck-x86-linux.so)
    by 0x804AE63: process_file (findtextrel.c:322)
    by 0x804909B: main (findtextrel.c:149)

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

index 80e451cef00b56dc770d0ccc3712baf8370d99b6..7d5e001b0e5399677f6276bdcf0c7cd07724bc07 100644 (file)
@@ -1,3 +1,7 @@
+2015-06-18  Mark Wielaard  <mjw@redhat.com>
+
+       * findtextrel.c (process_file): Free segments after use.
+
 2015-06-18  Mark Wielaard  <mjw@redhat.com>
 
        * readelf.c (print_phdr): Make sure phdr2_mem lifetime/scope equals
index 264a06bd96eb7a5e9fd06c3cb78df8937b80a5a9..6f1a4b5572ad5bd07580aff625ec95c43fdfbabb 100644 (file)
@@ -484,6 +484,7 @@ cannot get relocation at index %d in section %zu in '%s': %s"),
   if (fd2 != -1)
     close (fd2);
 
+  free (segments);
   tdestroy (knownsrcs, noop);
 
   return result;