aboutsummaryrefslogtreecommitdiffstats
path: root/g10/keygen.c
diff options
context:
space:
mode:
authorJakub Jelen <[email protected]>2021-04-12 18:05:48 +0000
committerWerner Koch <[email protected]>2021-05-20 12:42:29 +0000
commitfa0771f609b5fcb104c64a11aefc501b7a91696d (patch)
tree6e2929ab9eb917f4d2c9e2f44f456bcee06de838 /g10/keygen.c
parentdirmgr: Avoid double free (diff)
downloadgnupg-fa0771f609b5fcb104c64a11aefc501b7a91696d.tar.gz
gnupg-fa0771f609b5fcb104c64a11aefc501b7a91696d.zip
g10: Avoid memory leaks
* g10/call-agent.c (card_keyinfo_cb): free keyinfo. Restructure to avoid backward gotos. * g10/keyedit.c (menu_set_keyserver_url): properly enclose the block * g10/keygen.c (gen_card_key): free pk and pkt -- Signed-off-by: Jakub Jelen <[email protected]> GnuPG-bug-id: 5393 Additional changes: - Restructure to avoid backward gotos. Signed-off-by: Werner Koch <[email protected]>
Diffstat (limited to 'g10/keygen.c')
-rw-r--r--g10/keygen.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/g10/keygen.c b/g10/keygen.c
index f1e4d3638..82f6bb880 100644
--- a/g10/keygen.c
+++ b/g10/keygen.c
@@ -6140,12 +6140,20 @@ gen_card_key (int keyno, int algo, int is_primary, kbnode_t pub_root,
the self-signatures. */
err = agent_readkey (NULL, 1, keyid, &public);
if (err)
- return err;
+ {
+ xfree (pkt);
+ xfree (pk);
+ return err;
+ }
err = gcry_sexp_sscan (&s_key, NULL, public,
gcry_sexp_canon_len (public, 0, NULL, NULL));
xfree (public);
if (err)
- return err;
+ {
+ xfree (pkt);
+ xfree (pk);
+ return err;
+ }
if (algo == PUBKEY_ALGO_RSA)
err = key_from_sexp (pk->pkey, s_key, "public-key", "ne");