Skip to content

Commit

Permalink
Improve SCardReleaseContext fix
Browse files Browse the repository at this point in the history
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;
  • Loading branch information
LudovicRousseau committed Jun 19, 2022
1 parent d0e5947 commit d7a0887
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/winscard_svc.c
Original file line number Diff line number Diff line change
Expand Up @@ -891,7 +891,8 @@ static LONG MSGRemoveContext(SCARDCONTEXT hContext, SCONTEXT * threadContext)
* orphan handle.
*/
rv = RFReaderInfoById(hCard, &rContext);
if (rv != SCARD_S_SUCCESS && rv != SCARD_E_INVALID_VALUE)
if (rv != SCARD_S_SUCCESS && rv != SCARD_E_INVALID_VALUE
&& rv != SCARD_E_READER_UNAVAILABLE)
{
(void)pthread_mutex_unlock(&threadContext->cardsList_lock);
return rv;
Expand Down

0 comments on commit d7a0887

Please sign in to comment.