]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
libdwfl: Fix memory leak in __libdwfl_open_by_build_id.
authorMark Wielaard <mjw@redhat.com>
Mon, 1 Jun 2015 15:07:26 +0000 (17:07 +0200)
committerMark Wielaard <mjw@redhat.com>
Fri, 5 Jun 2015 12:52:29 +0000 (14:52 +0200)
commit c57829 introduced a memory leak by passing the path string to
strsep. strsep will change the given pointer and set it to NULL eventually.
Causing the original pointer to leak. Fix by passing a copy of the pointer
to strsep.

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

index f4e7484b5bab2388e272b266b9e7f13d3aa0d0da..4de383246da3de54f402fb48dbaad70b00a485dd 100644 (file)
@@ -1,3 +1,8 @@
+2015-06-01  Mark Wielaard  <mjw@redhat.com>
+
+       * dwfl_build_id_find_elf.c (__libdwfl_open_by_build_id): Copy path
+       pointer before passing to strsep.
+
 2015-05-30  Mark Wielaard  <mjw@redhat.com>
 
        * link_map.c (check32): Use read_4ubyte_unaligned_noncvt to read
index 215782a7c8e2cd91a077941a731d79c566c96d30..99a5059c9ddb627bc03c639ec8fe0825eed95b47 100644 (file)
@@ -73,7 +73,8 @@ __libdwfl_open_by_build_id (Dwfl_Module *mod, bool debug, char **file_name,
 
   int fd = -1;
   char *dir;
-  while (fd < 0 && (dir = strsep (&path, ":")) != NULL)
+  char *paths = path;
+  while (fd < 0 && (dir = strsep (&paths, ":")) != NULL)
     {
       if (dir[0] == '+' || dir[0] == '-')
        ++dir;