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=2096f4fe23ce48e5f40d4d6234f502b2e61d50d1

commit 2096f4fe23ce48e5f40d4d6234f502b2e61d50d1
Author: Guillem Jover <[email protected]>
AuthorDate: Tue Aug 25 01:13:12 2020 +0200

    u-a: Fix memory leaks for alternative database context on load errors
    
    Warned-by: gcc ASAN
---
 utils/update-alternatives.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/utils/update-alternatives.c b/utils/update-alternatives.c
index b98fbe1a6..0aeec5ad2 100644
--- a/utils/update-alternatives.c
+++ b/utils/update-alternatives.c
@@ -1465,8 +1465,10 @@ alternative_load(struct alternative *a, enum altdb_flags 
flags)
        /* Open the alternative file. */
        ctx.fh = fopen(ctx.filename, "r");
        if (ctx.fh == NULL) {
-               if (errno == ENOENT)
+               if (errno == ENOENT) {
+                       altdb_context_free(&ctx);
                        return false;
+               }
 
                syserr(_("unable to open file '%s'"), ctx.filename);
        }
@@ -1480,8 +1482,10 @@ alternative_load(struct alternative *a, enum altdb_flags 
flags)
        /* Verify the alternative is not empty. */
        if (fstat(fileno(ctx.fh), &st) == -1)
                syserr(_("cannot stat file '%s'"), ctx.filename);
-       if (st.st_size == 0)
+       if (st.st_size == 0) {
+               altdb_context_free(&ctx);
                return false;
+       }
 
        /* Start parsing mandatory attributes (link+status) of the alternative 
*/
        alternative_reset(a);

-- 
Dpkg.Org's dpkg

Reply via email to