From 60c880bda5c9b821fd2968cf89c38c37be3c1a7b Mon Sep 17 00:00:00 2001 From: NIIBE Yutaka Date: Fri, 14 Sep 2018 08:11:45 +0900 Subject: [PATCH] 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 --- g10/skclist.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/g10/skclist.c b/g10/skclist.c index 11c57e575..c9c41d0d9 100644 --- a/g10/skclist.c +++ b/g10/skclist.c @@ -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;