This is an automated email from the git hooks/post-receive script. guillem pushed a commit to branch master in repository dpkg.
View the commit online: https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=f13aebc8a05da51a54da55d55b023ca8199a6471 commit f13aebc8a05da51a54da55d55b023ca8199a6471 Author: Guillem Jover <[email protected]> AuthorDate: Tue Aug 18 01:36:00 2020 +0200 libdpkg: Fix single-instance memory leak with fsys dir This variable is usually set up once at the beginning of the execution and then never changed again. Warned-by: gcc ASAN --- lib/dpkg/fsys-dir.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/dpkg/fsys-dir.c b/lib/dpkg/fsys-dir.c index 15335b23e..40ccb7fe8 100644 --- a/lib/dpkg/fsys-dir.c +++ b/lib/dpkg/fsys-dir.c @@ -29,6 +29,7 @@ #include <dpkg/fsys.h> static const char *fsys_dir = ""; +static char *fsys_dir_alloc; /** * Set current on-disk filesystem root directory. @@ -45,22 +46,23 @@ static const char *fsys_dir = ""; const char * dpkg_fsys_set_dir(const char *dir) { - char *new_dir; - if (dir == NULL) { const char *env; env = getenv("DPKG_ROOT"); if (env) dir = env; - else - dir = ""; } - new_dir = m_strdup(dir); - path_trim_slash_slashdot(new_dir); + free(fsys_dir_alloc); - fsys_dir = new_dir; + if (dir == NULL) { + fsys_dir = ""; + fsys_dir_alloc = NULL; + } else { + fsys_dir = fsys_dir_alloc = m_strdup(dir); + path_trim_slash_slashdot(fsys_dir_alloc); + } return fsys_dir; } -- Dpkg.Org's dpkg

