arekinath/erlang-pcsc

beam crash when pcscd is not running

Closed this issue · 0 comments

when there is no pcscd is running to connect to (or whenever SCardEstablishContext(...)in pcsc_nif_new_context(...) returns something other than SCARD_S_SUCCESS), the enif_release_resource(ctx) call will lead to pcsc_nif_ctx_dtor() being run.
Since the ctx->pnc_mtx has not been created yet, trying to lock it does crash the beam vm:

Fatal error in erl_drv_mutex_lock(): Invalid argument [22]
Abort trap (core dumped)