mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-03 12:11:33 +01:00
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>
This commit is contained in:
parent
ef052591ba
commit
d68bdc553a
@ -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 */
|
||||
|
Loading…
x
Reference in New Issue
Block a user