g10: Fix another memory leak.

* g10/skclist.c (enum_secret_keys): Use SK_LIST instead of pubkey_t.

--

The use of pubkey_t was wrong.  The use is just a list of keys, not
with keyblock.  With SK_LIST, release_sk_list releases memory by
free_public_key.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
This commit is contained in:
NIIBE Yutaka 2018-09-14 08:11:45 +09:00
parent 2eb481e8cc
commit 60c880bda5
1 changed files with 3 additions and 4 deletions

View File

@ -337,7 +337,7 @@ enum_secret_keys (ctrl_t ctrl, void **context, PKT_public_key *sk)
kbnode_t keyblock;
kbnode_t node;
getkey_ctx_t ctx;
pubkey_t results;
SK_LIST results;
} *c = *context;
if (!c)
@ -358,7 +358,7 @@ enum_secret_keys (ctrl_t ctrl, void **context, PKT_public_key *sk)
/* Free the context. */
xfree (c->serialno);
free_strlist (c->card_list);
pubkeys_free (c->results);
release_sk_list (c->results);
release_kbnode (c->keyblock);
getkey_end (ctrl, c->ctx);
xfree (c);
@ -516,7 +516,7 @@ enum_secret_keys (ctrl_t ctrl, void **context, PKT_public_key *sk)
if (c->node->pkt->pkttype == PKT_PUBLIC_KEY
|| c->node->pkt->pkttype == PKT_PUBLIC_SUBKEY)
{
pubkey_t r;
SK_LIST r;
/* Skip this candidate if it's already enumerated. */
for (r = c->results; r; r = r->next)
@ -537,7 +537,6 @@ enum_secret_keys (ctrl_t ctrl, void **context, PKT_public_key *sk)
}
r->pk = sk;
r->keyblock = NULL;
r->next = c->results;
c->results = r;