diff options
author | NIIBE Yutaka <[email protected]> | 2018-09-13 23:02:16 +0000 |
---|---|---|
committer | NIIBE Yutaka <[email protected]> | 2018-09-13 23:02:16 +0000 |
commit | 2eb481e8cc1c37378cf68a06557c4a7a625d315c (patch) | |
tree | b4b5690376dfc3fe86e50907b4d23b2c21da6a81 /g10/skclist.c | |
parent | g10: Fix memory leak in enum_secret_keys. (diff) | |
download | gnupg-2eb481e8cc1c37378cf68a06557c4a7a625d315c.tar.gz gnupg-2eb481e8cc1c37378cf68a06557c4a7a625d315c.zip |
g10: Fix memory leak (more).
* g10/skclist.c (enum_secret_keys): Free SERIALNO on update.
--
Signed-off-by: NIIBE Yutaka <[email protected]>
Diffstat (limited to 'g10/skclist.c')
-rw-r--r-- | g10/skclist.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/g10/skclist.c b/g10/skclist.c index d23354968..11c57e575 100644 --- a/g10/skclist.c +++ b/g10/skclist.c @@ -380,6 +380,8 @@ enum_secret_keys (ctrl_t ctrl, void **context, PKT_public_key *sk) /* Loop over the list of secret keys. */ do { + char *serialno; + name = NULL; keyblock = NULL; switch (c->state) @@ -415,8 +417,6 @@ enum_secret_keys (ctrl_t ctrl, void **context, PKT_public_key *sk) case 4: /* Get next item from card list. */ if (c->sl) { - char *serialno; - err = agent_scd_serialno (&serialno, c->sl->d); if (err) { @@ -444,9 +444,13 @@ enum_secret_keys (ctrl_t ctrl, void **context, PKT_public_key *sk) } else { - if (c->serialno) - /* Select the original card again. */ - agent_scd_serialno (&c->serialno, c->serialno); + serialno = c->serialno; + if (serialno) + { + /* Select the original card again. */ + agent_scd_serialno (&c->serialno, serialno); + xfree (serialno); + } c->state++; } break; |