aboutsummaryrefslogtreecommitdiffstats
path: root/g10/skclist.c
diff options
context:
space:
mode:
authorNIIBE Yutaka <[email protected]>2018-09-13 22:55:20 +0000
committerNIIBE Yutaka <[email protected]>2018-09-13 22:55:20 +0000
commit64c5c45e2aa4a12d939680b9d51c8b26d61c5e9d (patch)
tree71eed178297b680781ca73f51851143e1e759976 /g10/skclist.c
parentRevert "dirmngr: hkp: Avoid potential race condition when some hosts die." (diff)
downloadgnupg-64c5c45e2aa4a12d939680b9d51c8b26d61c5e9d.tar.gz
gnupg-64c5c45e2aa4a12d939680b9d51c8b26d61c5e9d.zip
g10: Fix memory leak in enum_secret_keys.
* g10/skclist.c (enum_secret_keys): Don't forget to call free_public_key in the error return paths. -- Reported-by: Philippe Antoine GnuPG-bug-id: 4140 Signed-off-by: NIIBE Yutaka <[email protected]>
Diffstat (limited to 'g10/skclist.c')
-rw-r--r--g10/skclist.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/g10/skclist.c b/g10/skclist.c
index fd747fb2b..d23354968 100644
--- a/g10/skclist.c
+++ b/g10/skclist.c
@@ -345,7 +345,11 @@ enum_secret_keys (ctrl_t ctrl, void **context, PKT_public_key *sk)
/* Make a new context. */
c = xtrycalloc (1, sizeof *c);
if (!c)
- return gpg_error_from_syserror ();
+ {
+ err = gpg_error_from_syserror ();
+ free_public_key (sk);
+ return err;
+ }
*context = c;
}
@@ -363,7 +367,10 @@ enum_secret_keys (ctrl_t ctrl, void **context, PKT_public_key *sk)
}
if (c->eof)
- return gpg_error (GPG_ERR_EOF);
+ {
+ free_public_key (sk);
+ return gpg_error (GPG_ERR_EOF);
+ }
for (;;)
{
@@ -475,6 +482,7 @@ enum_secret_keys (ctrl_t ctrl, void **context, PKT_public_key *sk)
default: /* No more names to check - stop. */
c->eof = 1;
+ free_public_key (sk);
return gpg_error (GPG_ERR_EOF);
}
}