[Pcsclite-cvs-commit] r6681 - trunk/Drivers/ccid/src

ludovic.rousseau at free.fr ludovic.rousseau at free.fr
Sun Jul 28 09:30:21 UTC 2013


Author: rousseau
Date: 2013-07-01 08:54:13 +0000 (Mon, 01 Jul 2013)
New Revision: 6681

Modified:
   trunk/Drivers/ccid/src/ccid_usb.c
Log:
CloseUSB(): free arrayOfSupportedDataRates on the last slot close

Do free .ccid.arrayOfSupportedDataRates array only when the last slot is
closed.

Multi-slot readers share the same .ccid.arrayOfSupportedDataRates array.

The GEMCOREPOSPRO and GEMCORESIMPRO are an exception and are not
correctly managed by this patch (memory may leak).


Modified: trunk/Drivers/ccid/src/ccid_usb.c
===================================================================
--- trunk/Drivers/ccid/src/ccid_usb.c	2013-07-01 08:34:26 UTC (rev 6680)
+++ trunk/Drivers/ccid/src/ccid_usb.c	2013-07-01 08:54:13 UTC (rev 6681)
@@ -815,13 +815,6 @@
 		usbDevice[reader_index].bus_number,
 		usbDevice[reader_index].device_address);
 
-	if (usbDevice[reader_index].ccid.arrayOfSupportedDataRates
-		&& (usbDevice[reader_index].ccid.bCurrentSlotIndex == 0))
-	{
-		free(usbDevice[reader_index].ccid.arrayOfSupportedDataRates);
-		usbDevice[reader_index].ccid.arrayOfSupportedDataRates = NULL;
-	}
-
 	/* one slot closed */
 	(*usbDevice[reader_index].nb_opened_slots)--;
 
@@ -863,6 +856,9 @@
 		if (DriverOptions & DRIVER_OPTION_RESET_ON_CLOSE)
 			(void)libusb_reset_device(usbDevice[reader_index].dev_handle);
 
+		if (usbDevice[reader_index].ccid.arrayOfSupportedDataRates)
+			free(usbDevice[reader_index].ccid.arrayOfSupportedDataRates);
+
 		(void)libusb_release_interface(usbDevice[reader_index].dev_handle,
 			usbDevice[reader_index].interface);
 		(void)libusb_close(usbDevice[reader_index].dev_handle);




More information about the Pcsclite-cvs-commit mailing list