Hello Ludovic,

please merge patch in attachment, the issue was found using valgrind.

Kind regards,
--
  Giuseppe M
  https://keybase.io/gdm85
Index: src/winscard_svc.c
===================================================================
--- src/winscard_svc.c	(revision 7003)
+++ src/winscard_svc.c	(working copy)
@@ -184,7 +184,9 @@
 	if (listSize >= contextMaxThreadCounter)
 	{
 		Log2(PCSC_LOG_CRITICAL, "Too many context running: %d", listSize);
-		goto out;
+		
+		//NOTE: will exit with SCARD_E_NO_MEMORY although this is not an out of memory error
+		goto outNoUnlock;
 	}
 
 	/* Create the context for this thread. */
@@ -192,7 +194,7 @@
 	if (NULL == newContext)
 	{
 		Log1(PCSC_LOG_CRITICAL, "Could not allocate new context");
-		goto out;
+		goto outNoUnlock;
 	}
 	memset(newContext, 0, sizeof(*newContext));
 
@@ -203,7 +205,7 @@
 	if (lrv < 0)
 	{
 		Log2(PCSC_LOG_CRITICAL, "list_init failed with return value: %d", lrv);
-		goto out;
+		goto outNoUnlock;
 	}
 
 	/* request to store copies, and provide the metric function */
@@ -221,7 +223,7 @@
 		Log2(PCSC_LOG_CRITICAL,
 			"list_attributes_comparator failed with return value: %d", lrv);
 		list_destroy(&newContext->cardsList);
-		goto out;
+		goto outNoUnlock;
 	}
 
 	(void)pthread_mutex_init(&newContext->cardsList_lock, NULL);
@@ -258,6 +260,7 @@
 out:
 	(void)pthread_mutex_unlock(&contextsList_lock);
 
+outNoUnlock:
 	if (retval != SCARD_S_SUCCESS)
 	{
 		if (newContext)
_______________________________________________
Pcsclite-muscle mailing list
[email protected]
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pcsclite-muscle

Reply via email to