]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
libdwfl: Fix memory leak in dwfl_module_getsrc_file on invalid DWARF.
authorMark Wielaard <mjw@redhat.com>
Thu, 14 Apr 2016 19:53:33 +0000 (21:53 +0200)
committerMark Wielaard <mjw@redhat.com>
Thu, 14 Apr 2016 19:53:33 +0000 (21:53 +0200)
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 <mjw@redhat.com>
libdwfl/ChangeLog
libdwfl/dwfl_module_getsrc_file.c

index 60ed7009ef47ae6adca72ad654e4bbf2f190bd1d..bdfc92f1b7f146cbe8977476732cbc15502419f2 100644 (file)
@@ -1,3 +1,8 @@
+2016-04-14  Mark Wielaard  <mjw@redhat.com>
+
+       * dwfl_module_getsrc_file.c (dwfl_module_getsrc_file): Free match
+       on invalid DWARF if we allocated it.
+
 2016-04-14  Mark Wielaard  <mjw@redhat.com>
 
        * linux-proc-maps.c (proc_maps_report): Free last_file on bad file
index 21a59159248abe8890e4a043dcb7b7e6597d3a86..4eaaeaffaf60b3167f98003faf3568cf2b36d8f3 100644 (file)
@@ -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;
            }