From: Mark Wielaard Date: Thu, 14 Apr 2016 19:53:33 +0000 (+0200) Subject: libdwfl: Fix memory leak in dwfl_module_getsrc_file on invalid DWARF. X-Git-Tag: elfutils-0.167~26 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f46ba1e7211f4ae884f234a37e16bc5feafa2b1c;p=thirdparty%2Felfutils.git libdwfl: Fix memory leak in dwfl_module_getsrc_file on invalid DWARF. If we allocated the match results array ourselves, then free it when we detect invalid DWARF and return an error. Signed-off-by: Mark Wielaard --- diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog index 60ed7009e..bdfc92f1b 100644 --- a/libdwfl/ChangeLog +++ b/libdwfl/ChangeLog @@ -1,3 +1,8 @@ +2016-04-14 Mark Wielaard + + * dwfl_module_getsrc_file.c (dwfl_module_getsrc_file): Free match + on invalid DWARF if we allocated it. + 2016-04-14 Mark Wielaard * linux-proc-maps.c (proc_maps_report): Free last_file on bad file diff --git a/libdwfl/dwfl_module_getsrc_file.c b/libdwfl/dwfl_module_getsrc_file.c index 21a591592..4eaaeaffa 100644 --- a/libdwfl/dwfl_module_getsrc_file.c +++ b/libdwfl/dwfl_module_getsrc_file.c @@ -87,6 +87,8 @@ dwfl_module_getsrc_file (Dwfl_Module *mod, if (unlikely (line->file >= line->files->nfiles)) { + if (*nsrcs == 0) + free (match); __libdwfl_seterrno (DWFL_E (LIBDW, DWARF_E_INVALID_DWARF)); return -1; }