From mboxrd@z Thu Jan 1 00:00:00 1970 Content-Type: multipart/mixed; boundary="===============7150800315073186254==" MIME-Version: 1.0 From: Mark Wielaard To: elfutils-devel@lists.fedorahosted.org Subject: [PATCH] libdwfl: Fix memory leak in proc_maps_report on bad file mapping. Date: Thu, 14 Apr 2016 21:34:23 +0200 Message-ID: <1460662463-8179-1-git-send-email-mjw@redhat.com> --===============7150800315073186254== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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 --- libdwfl/ChangeLog | 5 +++++ libdwfl/linux-proc-maps.c | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog index 5d400bb..60ed700 100644 --- a/libdwfl/ChangeLog +++ b/libdwfl/ChangeLog @@ -1,3 +1,8 @@ +2016-04-14 Mark Wielaard + + * linux-proc-maps.c (proc_maps_report): Free last_file on bad file + mapping. + 2016-03-01 Steven Chamberlain = * linux-pid-attach.c: Removed unused pid_thread_callbacks, diff --git a/libdwfl/linux-proc-maps.c b/libdwfl/linux-proc-maps.c index 94b26d5..4ae1e74 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 sysin= fo_ehdr, pid_t pid) { /* This is another portion of the same file's mapping. */ if (strcmp (last_file, file) !=3D 0) - goto bad_report; + { + free (last_file); + goto bad_report; + } high =3D end; } else -- = 2.5.5 --===============7150800315073186254==--