From 455afb11344a560dbf2e76f26444f3ebbc103b1c Mon Sep 17 00:00:00 2001 From: Santiago Gimeno Date: Fri, 22 Jan 2016 10:03:44 +0100 Subject: [PATCH] src: fix readers_name memory deletion - After implementing SCARD_AUTOALLOCATE functionality for getting card readers name, the deletion of the allocated memory in `PCSCLite:: HandleReaderStatusChange` was not correctly migrated and was causing serious issues in `Windows`. - See: https://github.com/santigimeno/node-pcsclite/issues/45. --- src/pcsclite.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/pcsclite.cpp b/src/pcsclite.cpp index 2321de3..42d9bbb 100644 --- a/src/pcsclite.cpp +++ b/src/pcsclite.cpp @@ -159,7 +159,12 @@ void PCSCLite::HandleReaderStatusChange(uv_async_t *handle, int status) { } /* reset AsyncResult */ +#ifdef SCARD_AUTOALLOCATE + PCSCLite* pcsclite = async_baton->pcsclite; + SCardFreeMemory(pcsclite->m_card_context, ar->readers_name); +#else delete [] ar->readers_name; +#endif ar->readers_name = NULL; ar->readers_name_length = 0; ar->result = SCARD_S_SUCCESS;