1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-12-22 10:19:57 +01:00

scd: Don't release the context until list_finish for PC/SC.

* scd/apdu.c (apdu_dev_list_start): Increment PCSC.COUNT here.
(apdu_dev_list_finish): Decrement PCSC.COUNT.

--

GnuPG-bug-id: 5416
Fixes-commit: 32baa9acfb153004bdb2509f9516482b78f256a4
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
This commit is contained in:
NIIBE Yutaka 2021-08-20 15:22:28 +09:00
parent c1a23c3664
commit 1565baa93a

View File

@ -2087,6 +2087,13 @@ apdu_dev_list_start (const char *portstr, struct dev_list **l_p)
break;
}
}
/*
* Increment PCSC.COUNT artificially, so that PCSC.CONTEXT can
* be kept (not released) until apdu_dev_list_finish will be
* called.
*/
pcsc.count++;
}
*l_p = dl;
@ -2112,7 +2119,7 @@ apdu_dev_list_finish (struct dev_list *dl)
pcsc.rdrname[i] = NULL;
npth_mutex_lock (&reader_table_lock);
if (pcsc.count == 0)
if (--pcsc.count == 0)
release_pcsc_context ();
npth_mutex_unlock (&reader_table_lock);
}