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=1dd925c8749829db25c95e12b4b1d7c8842d391f

commit 1dd925c8749829db25c95e12b4b1d7c8842d391f
Author: Guillem Jover <[email protected]>
AuthorDate: Tue Aug 18 02:09:08 2020 +0200

    dpkg-divert: Fix short-lived memory leaks
    
    Warned-by: gcc ASAN
---
 src/divertcmd.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/src/divertcmd.c b/src/divertcmd.c
index e4bf3b58c..8836e67aa 100644
--- a/src/divertcmd.c
+++ b/src/divertcmd.c
@@ -133,7 +133,7 @@ opt_rename_setup(void)
 }
 
 struct file {
-       const char *name;
+       char *name;
        enum {
                FILE_STAT_INVALID,
                FILE_STAT_VALID,
@@ -155,6 +155,12 @@ file_init(struct file *f, const char *filename)
        f->stat_state = FILE_STAT_INVALID;
 }
 
+static void
+file_destroy(struct file *f)
+{
+       free(f->name);
+}
+
 static void
 file_stat(struct file *f)
 {
@@ -512,6 +518,10 @@ diversion_add(const char *const *argv)
                        if (opt_verbose > 0)
                                printf(_("Leaving '%s'\n"),
                                       diversion_describe(fnn_from->divert));
+
+                       file_destroy(&file_from);
+                       file_destroy(&file_to);
+
                        return 0;
                }
 
@@ -558,6 +568,9 @@ diversion_add(const char *const *argv)
                        file_rename(&file_from, &file_to);
        }
 
+       file_destroy(&file_from);
+       file_destroy(&file_to);
+
        return 0;
 }
 
@@ -669,6 +682,9 @@ diversion_remove(const char *const *argv)
        if (!opt_test)
                divertdb_write();
 
+       file_destroy(&file_from);
+       file_destroy(&file_to);
+
        return 0;
 }
 

-- 
Dpkg.Org's dpkg

Reply via email to