1
0
mirror of git://git.gnupg.org/gnupg.git synced 2025-01-03 12:11:33 +01:00

scd: Fix memory leaks.

* scd/apdu.c (apdu_dev_list_start): Free DL.
* scd/app-nks.c (pubkey_from_pk_file): Fix typo in condition.

--

GnuPG-bug-id: 5393
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
This commit is contained in:
Jakub Jelen 2021-04-13 14:21:29 +09:00 committed by NIIBE Yutaka
parent cd66b2eb0d
commit 7cbe29c4fb
2 changed files with 5 additions and 1 deletions

View File

@ -1985,6 +1985,7 @@ apdu_dev_list_start (const char *portstr, struct dev_list **l_p)
err = ccid_dev_scan (&dl->idx_max, &dl->table);
if (err)
{
xfree (dl);
npth_mutex_unlock (&reader_table_lock);
return err;
}
@ -2009,6 +2010,7 @@ apdu_dev_list_start (const char *portstr, struct dev_list **l_p)
if (!pcsc.context)
if (pcsc_init () < 0)
{
xfree (dl);
npth_mutex_unlock (&reader_table_lock);
return gpg_error (GPG_ERR_NO_SERVICE);
}
@ -2023,6 +2025,7 @@ apdu_dev_list_start (const char *portstr, struct dev_list **l_p)
log_error ("error allocating memory for reader list\n");
close_pcsc_reader (0);
xfree (dl);
npth_mutex_unlock (&reader_table_lock);
return err;
}
@ -2034,6 +2037,7 @@ apdu_dev_list_start (const char *portstr, struct dev_list **l_p)
pcsc_error_string (r), r);
xfree (p);
close_pcsc_reader (0);
xfree (dl);
npth_mutex_unlock (&reader_table_lock);
return iso7816_map_sw (pcsc_error_to_sw (r));
}

View File

@ -372,7 +372,7 @@ pubkey_from_pk_file (app_t app, int pkfid, int cfid,
newlen = 1 + buflen[i] - offset[i];
newbuf = xtrymalloc (newlen);
if (!newlen)
if (!newbuf)
{
err = gpg_error_from_syserror ();
xfree (buffer[0]);