summaryrefslogtreecommitdiffstats
path: root/scd
diff options
context:
space:
mode:
authorNIIBE Yutaka <gniibe@fsij.org>2021-05-07 04:25:20 +0200
committerNIIBE Yutaka <gniibe@fsij.org>2021-05-07 04:25:20 +0200
commit0498ea8fbd57d0df3093301d551db6b287ccf622 (patch)
tree91bc8e1579d85cea5dc43c48c8c957cde67d810e /scd
parentscd: Fix memory leak for RDRNAME and serialize access. (diff)
downloadgnupg2-0498ea8fbd57d0df3093301d551db6b287ccf622.tar.xz
gnupg2-0498ea8fbd57d0df3093301d551db6b287ccf622.zip
scd: Increment PCSC.COUNT correctly.
* scd/apdu.c (open_pcsc_reader): PCSC.COUNT should be incremented before possible call of close_pcsc_reader. -- Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
Diffstat (limited to 'scd')
-rw-r--r--scd/apdu.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/scd/apdu.c b/scd/apdu.c
index d34127a10..34e606ada 100644
--- a/scd/apdu.c
+++ b/scd/apdu.c
@@ -1237,11 +1237,12 @@ open_pcsc_reader (const char *rdrname)
if (slot == -1)
return -1;
+ pcsc.count++;
reader_table[slot].rdrname = xtrystrdup (rdrname);
if (!reader_table[slot].rdrname)
{
log_error ("error allocating memory for reader name\n");
- close_pcsc_reader (0);
+ close_pcsc_reader (slot);
reader_table[slot].used = 0;
unlock_slot (slot);
return -1;
@@ -1258,7 +1259,6 @@ open_pcsc_reader (const char *rdrname)
reader_table[slot].send_apdu_reader = pcsc_send_apdu;
reader_table[slot].dump_status_reader = dump_pcsc_reader_status;
- pcsc.count++;
dump_reader_status (slot);
unlock_slot (slot);
return slot;