mirror of
git://git.gnupg.org/gnupg.git
synced 2024-12-22 10:19:57 +01:00
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 <gniibe@fsij.org>
This commit is contained in:
parent
69bab1cba0
commit
64c5c45e2a
@ -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);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user