summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Wielaard <mjw@redhat.com>2016-04-14 21:32:55 +0200
committerMark Wielaard <mjw@redhat.com>2016-04-14 21:32:55 +0200
commit2eedce110ac090c55aed4756152b6deb16229cdd (patch)
tree9a7cfab75c3d200a2e39bccec642647d5e8d0a97
parentf7f45ed580029d80e6cf5bcfa5d5445af797e363 (diff)
downloadelfutils-2eedce110ac090c55aed4756152b6deb16229cdd.tar.gz
libdwfl: Fix memory leak in proc_maps_report on bad file mapping.
Normally last_file is freed inside report(), but in the case of a bad file mapping we don't call report. Signed-off-by: Mark Wielaard <mjw@redhat.com>
-rw-r--r--libdwfl/ChangeLog5
-rw-r--r--libdwfl/linux-proc-maps.c5
2 files changed, 9 insertions, 1 deletions
diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog
index 5d400bb1..60ed7009 100644
--- a/libdwfl/ChangeLog
+++ b/libdwfl/ChangeLog
@@ -1,3 +1,8 @@
+2016-04-14 Mark Wielaard <mjw@redhat.com>
+
+ * linux-proc-maps.c (proc_maps_report): Free last_file on bad file
+ mapping.
+
2016-03-01 Steven Chamberlain <steven@pyro.eu.org>
* linux-pid-attach.c: Removed unused pid_thread_callbacks,
diff --git a/libdwfl/linux-proc-maps.c b/libdwfl/linux-proc-maps.c
index 94b26d59..4ae1e74a 100644
--- a/libdwfl/linux-proc-maps.c
+++ b/libdwfl/linux-proc-maps.c
@@ -250,7 +250,10 @@ proc_maps_report (Dwfl *dwfl, FILE *f, GElf_Addr sysinfo_ehdr, pid_t pid)
{
/* This is another portion of the same file's mapping. */
if (strcmp (last_file, file) != 0)
- goto bad_report;
+ {
+ free (last_file);
+ goto bad_report;
+ }
high = end;
}
else