diff options
author | Neal H. Walfield <neal@g10code.com> | 2015-10-29 10:01:43 +0100 |
---|---|---|
committer | Neal H. Walfield <neal@g10code.com> | 2015-10-29 10:10:41 +0100 |
commit | d68bdc553a206e54234d5d53ad35c4ba34133118 (patch) | |
tree | 9eef396acd264f026108517877a2cfe679407ac3 /g10/trustdb.c | |
parent | gpg: Remove unused prototype. (diff) | |
download | gnupg2-d68bdc553a206e54234d5d53ad35c4ba34133118.tar.xz gnupg2-d68bdc553a206e54234d5d53ad35c4ba34133118.zip |
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@g10code.com>
Diffstat (limited to '')
-rw-r--r-- | g10/trustdb.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/g10/trustdb.c b/g10/trustdb.c index 32061e41c..54a779e08 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 */ |