diff options
| author | Mark Wielaard <[email protected]> | 2015-06-01 17:07:26 +0200 |
|---|---|---|
| committer | Mark Wielaard <[email protected]> | 2015-06-05 14:52:29 +0200 |
| commit | 8aaf4fc46f5b0b1ed2b567734d06875a39047dd9 (patch) | |
| tree | 36d62601054f50e8a10da849adc1e5215fc41353 | |
| parent | f17a9bbc2963854090b81fdf58e49dc8dc6ccfba (diff) | |
libdwfl: Fix memory leak in __libdwfl_open_by_build_id.
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 <[email protected]>
| -rw-r--r-- | libdwfl/ChangeLog | 5 | ||||
| -rw-r--r-- | libdwfl/dwfl_build_id_find_elf.c | 3 |
2 files changed, 7 insertions, 1 deletions
diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog index f4e7484b..4de38324 100644 --- a/libdwfl/ChangeLog +++ b/libdwfl/ChangeLog @@ -1,3 +1,8 @@ +2015-06-01 Mark Wielaard <[email protected]> + + * dwfl_build_id_find_elf.c (__libdwfl_open_by_build_id): Copy path + pointer before passing to strsep. + 2015-05-30 Mark Wielaard <[email protected]> * link_map.c (check32): Use read_4ubyte_unaligned_noncvt to read diff --git a/libdwfl/dwfl_build_id_find_elf.c b/libdwfl/dwfl_build_id_find_elf.c index 215782a7..99a5059c 100644 --- a/libdwfl/dwfl_build_id_find_elf.c +++ b/libdwfl/dwfl_build_id_find_elf.c @@ -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; |
