From 1070eb71b6601f6867159b04d115cb2f6435bcad Mon Sep 17 00:00:00 2001 From: Feitian Technologies Date: Tue, 12 May 2020 23:49:58 +0800 Subject: [PATCH] Update pcsc.c SCardFreeMemory function not supported in macOS, if the system is macOS, change to free API to release the resource. --- libnfc/drivers/pcsc.c | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/libnfc/drivers/pcsc.c b/libnfc/drivers/pcsc.c index 9bd5e18..bbd575a 100644 --- a/libnfc/drivers/pcsc.c +++ b/libnfc/drivers/pcsc.c @@ -760,10 +760,33 @@ pcsc_get_information_about(nfc_device *pnd, char **pbuf) ? "\nserial: " : "", serial_len > 0 ? (char *)serial : ""); error: - SCardFreeMemory(*pscc, name); - SCardFreeMemory(*pscc, type); - SCardFreeMemory(*pscc, version); - SCardFreeMemory(*pscc, serial); +// SCardFreeMemory function not supported in macOS. +#if defined(__APPLE__) + if (name != NULL){ + free(name); + name = NULL; + } + if (type != NULL){ + free(type); + type = NULL; + } + if (version != NULL){ + free(version); + version = NULL; + } + if (serial != NULL){ + free(serial); + serial = NULL; + } + if (pscc != NULL){ + SCardReleaseContext(pscc); + } +#else + SCardFreeMemory(*pscc, name); SCardFreeMemory(*pscc, name); + SCardFreeMemory(*pscc, type); SCardFreeMemory(*pscc, type); + SCardFreeMemory(*pscc, version); SCardFreeMemory(*pscc, version); + SCardFreeMemory(*pscc, serial); SCardFreeMemory(*pscc, serial); +#endif pnd->last_error = res; return pnd->last_error;