This is an automated email from the git hooks/post-receive script.

guillem pushed a commit to branch main
in repository dpkg.

View the commit online:
https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=4ca5e174e43cc784f6b3ea7d2cb7b46fff6d7212

commit 4ca5e174e43cc784f6b3ea7d2cb7b46fff6d7212 (HEAD -> main)
Author: Guillem Jover <guil...@debian.org>
AuthorDate: Mon Nov 29 00:38:01 2021 +0100

    dpkg: Fix short lived memory leak with --recursive
    
    Warned-by: gcc ASAN
---
 src/archives.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/archives.c b/src/archives.c
index a2aeb2b92..92340b936 100644
--- a/src/archives.c
+++ b/src/archives.c
@@ -1495,7 +1495,7 @@ int
 archivefiles(const char *const *argv)
 {
   const char *const *volatile argp;
-  const char **volatile arglist = NULL;
+  char **volatile arglist = NULL;
   int i;
   jmp_buf ejbuf;
   enum modstatdb_rw msdbflags;
@@ -1553,7 +1553,7 @@ archivefiles(const char *const *argv)
       ohshit(_("searched, but found no packages (files matching *.deb)"));
 
     arglist[nfiles] = NULL;
-    argp= arglist;
+    argp = (const char **volatile)arglist;
   } else {
     if (!*argv) badusage(_("--%s needs at least one package archive file 
argument"),
                          cipaction->olong);
@@ -1612,7 +1612,11 @@ archivefiles(const char *const *argv)
 
   dpkg_selabel_close();
 
-  free(arglist);
+  if (arglist) {
+    for (i = 0; arglist[i]; i++)
+      free(arglist[i]);
+    free(arglist);
+  }
 
   switch (cipaction->arg_int) {
   case act_install:

-- 
Dpkg.Org's dpkg

Reply via email to