mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-20 14:37:08 +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)
|
if (rc)
|
||||||
{
|
{
|
||||||
log_error ("keydb_search_first failed: %s\n", gpg_strerror (rc));
|
log_error ("keydb_search(first) failed: %s\n", gpg_strerror (rc));
|
||||||
xfree (keys);
|
goto die;
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
desc.mode = KEYDB_SEARCH_MODE_NEXT; /* change mode */
|
desc.mode = KEYDB_SEARCH_MODE_NEXT; /* change mode */
|
||||||
@ -1746,8 +1745,7 @@ validate_key_list (KEYDB_HANDLE hd, KeyHashTable full_trust,
|
|||||||
if (rc)
|
if (rc)
|
||||||
{
|
{
|
||||||
log_error ("keydb_get_keyblock failed: %s\n", gpg_strerror (rc));
|
log_error ("keydb_get_keyblock failed: %s\n", gpg_strerror (rc));
|
||||||
xfree (keys);
|
goto die;
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( keyblock->pkt->pkttype != PKT_PUBLIC_KEY)
|
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)
|
if (rc && gpg_err_code (rc) != GPG_ERR_NOT_FOUND)
|
||||||
{
|
{
|
||||||
log_error ("keydb_search_next failed: %s\n", gpg_strerror (rc));
|
log_error ("keydb_search_next failed: %s\n", gpg_strerror (rc));
|
||||||
xfree (keys);
|
goto die;
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
keys[nkeys].keyblock = NULL;
|
keys[nkeys].keyblock = NULL;
|
||||||
return keys;
|
return keys;
|
||||||
|
|
||||||
|
die:
|
||||||
|
keys[nkeys].keyblock = NULL;
|
||||||
|
release_key_array (keys);
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Caller must sync */
|
/* Caller must sync */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user