1
0
mirror of git://git.gnupg.org/gnupg.git synced 2025-01-18 14:17:03 +01:00

g10: Fix memory leak.

* g10/trustdb.c (tdb_get_validity_core): Fix kbnode leak.

Signed-off-by: Justus Winter <justus@g10code.com>
This commit is contained in:
Justus Winter 2016-07-01 12:48:57 +02:00
parent 5fafd18d47
commit 44d4c69572

View File

@ -1022,17 +1022,18 @@ tdb_get_validity_core (ctrl_t ctrl,
#ifdef USE_TOFU #ifdef USE_TOFU
if (opt.trust_model == TM_TOFU || opt.trust_model == TM_TOFU_PGP) if (opt.trust_model == TM_TOFU || opt.trust_model == TM_TOFU_PGP)
{ {
kbnode_t user_id_node = NULL; /* Silence -Wmaybe-uninitialized. */ kbnode_t user_id_node = NULL;
kbnode_t n = NULL; /* Silence -Wmaybe-uninitialized. */
int user_ids = 0; int user_ids = 0;
int user_ids_expired = 0; int user_ids_expired = 0;
/* If the caller didn't supply a user id then iterate over all /* If the caller didn't supply a user id then iterate over all
uids. */ uids. */
if (! uid) if (! uid)
user_id_node = get_pubkeyblock (main_pk->keyid); user_id_node = n = get_pubkeyblock (main_pk->keyid);
while (uid while (uid
|| (user_id_node = find_next_kbnode (user_id_node, PKT_USER_ID))) || (n = find_next_kbnode (n, PKT_USER_ID)))
{ {
unsigned int tl; unsigned int tl;
PKT_user_id *user_id; PKT_user_id *user_id;
@ -1040,7 +1041,7 @@ tdb_get_validity_core (ctrl_t ctrl,
if (uid) if (uid)
user_id = uid; user_id = uid;
else else
user_id = user_id_node->pkt->pkt.user_id; user_id = n->pkt->pkt.user_id;
/* If the user id is revoked or expired, then skip it. */ /* If the user id is revoked or expired, then skip it. */
if (user_id->is_revoked || user_id->is_expired) if (user_id->is_revoked || user_id->is_expired)
@ -1094,6 +1095,7 @@ tdb_get_validity_core (ctrl_t ctrl,
now. */ now. */
break; break;
} }
release_kbnode (user_id_node);
} }
#endif /*USE_TOFU*/ #endif /*USE_TOFU*/