Skip to content

Commit d7a0887

Browse files
Improve SCardReleaseContext fix
From Maksim Ivanov: SCARD_E_READER_UNAVAILABLE can be returned by RFReaderInfoById(): it's a corner case when the reader context is still there, but has a zero reference count. See RFReaderInfoById() using the REF_READER macro, which calls _RefReader() (and returns its error code on error), which in turn has this code: if (0 == sReader->reference) return SCARD_E_READER_UNAVAILABLE;
1 parent d0e5947 commit d7a0887

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/winscard_svc.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -891,7 +891,8 @@ static LONG MSGRemoveContext(SCARDCONTEXT hContext, SCONTEXT * threadContext)
891891
* orphan handle.
892892
*/
893893
rv = RFReaderInfoById(hCard, &rContext);
894-
if (rv != SCARD_S_SUCCESS && rv != SCARD_E_INVALID_VALUE)
894+
if (rv != SCARD_S_SUCCESS && rv != SCARD_E_INVALID_VALUE
895+
&& rv != SCARD_E_READER_UNAVAILABLE)
895896
{
896897
(void)pthread_mutex_unlock(&threadContext->cardsList_lock);
897898
return rv;

0 commit comments

Comments
 (0)