[Pkg-gnupg-commit] [gnupg2] 87/241: gpg: Eliminate a memory leak.

Daniel Kahn Gillmor dkg at fifthhorseman.net
Wed Dec 9 20:31:59 UTC 2015


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

dkg pushed a commit to branch master
in repository gnupg2.

commit d68bdc553a206e54234d5d53ad35c4ba34133118
Author: Neal H. Walfield <neal at g10code.com>
Date:   Thu Oct 29 10:01:43 2015 +0100

    gpg: Eliminate a memory leak.
    
    * g10/trustdb.c (validate_key_list): Don't leak the keyblocks on
    failure.
    
    --
    Signed-off-by: Neal H. Walfield <neal at g10code.com>
---
 g10/trustdb.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/g10/trustdb.c b/g10/trustdb.c
index 32061e4..54a779e 100644
--- a/g10/trustdb.c
+++ b/g10/trustdb.c
@@ -1729,9 +1729,8 @@ validate_key_list (KEYDB_HANDLE hd, KeyHashTable full_trust,
     }
   if (rc)
     {
-      log_error ("keydb_search_first failed: %s\n", gpg_strerror (rc));
-      xfree (keys);
-      return NULL;
+      log_error ("keydb_search(first) failed: %s\n", gpg_strerror (rc));
+      goto die;
     }
 
   desc.mode = KEYDB_SEARCH_MODE_NEXT; /* change mode */
@@ -1746,8 +1745,7 @@ validate_key_list (KEYDB_HANDLE hd, KeyHashTable full_trust,
       if (rc)
         {
           log_error ("keydb_get_keyblock failed: %s\n", gpg_strerror (rc));
-          xfree (keys);
-          return NULL;
+	  goto die;
         }
 
       if ( keyblock->pkt->pkttype != PKT_PUBLIC_KEY)
@@ -1804,12 +1802,16 @@ validate_key_list (KEYDB_HANDLE hd, KeyHashTable full_trust,
   if (rc && gpg_err_code (rc) != GPG_ERR_NOT_FOUND)
     {
       log_error ("keydb_search_next failed: %s\n", gpg_strerror (rc));
-      xfree (keys);
-      return NULL;
+      goto die;
     }
 
   keys[nkeys].keyblock = NULL;
   return keys;
+
+ die:
+  keys[nkeys].keyblock = NULL;
+  release_key_array (keys);
+  return NULL;
 }
 
 /* Caller must sync */

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-gnupg/gnupg2.git



More information about the Pkg-gnupg-commit mailing list