The API documentation for SCardStatus() does not state that it is valid to specify NULL for pdwState or pdwProtocol, however some applications seem to do this anyway.
It is tolerated without errors in pcsc-lite, so we probably need to follow suit. We have not checked how Windows behaves.
Should probably check the other calls for similar issues.
Should be fixed now. Unfortunately we don't have the software to reproduce the crash here so a code review or synthetic test case will have to do.
Code looks good. Smart card tunneling still works, tested with ThinLinc server build 6492.r35050.