[Pcsclite-cvs-commit] r6218 - /trunk/Drivers/ccid/src/ifdhandler.c
rousseau at users.alioth.debian.org
rousseau at users.alioth.debian.org
Mon Feb 13 08:55:34 UTC 2012
Author: rousseau
Date: Mon Feb 13 08:55:33 2012
New Revision: 6218
URL: http://svn.debian.org/wsvn/pcsclite/?sc=1&rev=6218
Log:
IFDHCreateChannelByName(): favctorize code
The code used to release the allocated resources is no more duplicated
in two places.
Modified:
trunk/Drivers/ccid/src/ifdhandler.c
Modified: trunk/Drivers/ccid/src/ifdhandler.c
URL: http://svn.debian.org/wsvn/pcsclite/trunk/Drivers/ccid/src/ifdhandler.c?rev=6218&op=diff
==============================================================================
--- trunk/Drivers/ccid/src/ifdhandler.c (original)
+++ trunk/Drivers/ccid/src/ifdhandler.c Mon Feb 13 08:55:33 2012
@@ -105,9 +105,7 @@
else
return_value = IFD_COMMUNICATION_ERROR;
- /* release the allocated resources */
- free(CcidSlots[reader_index].readerName);
- ReleaseReaderIndex(reader_index);
+ goto error;
}
else
{
@@ -135,10 +133,6 @@
{
DEBUG_CRITICAL("failed");
return_value = IFD_COMMUNICATION_ERROR;
-
- /* release the allocated resources */
- (void)ClosePort(reader_index);
- ReleaseReaderIndex(reader_index);
}
else
{
@@ -154,9 +148,17 @@
}
}
+error:
#ifdef HAVE_PTHREAD
(void)pthread_mutex_unlock(&ifdh_context_mutex);
#endif
+
+ if (return_value != IFD_SUCCESS)
+ {
+ /* release the allocated resources */
+ free(CcidSlots[reader_index].readerName);
+ ReleaseReaderIndex(reader_index);
+ }
return return_value;
} /* IFDHCreateChannelByName */
More information about the Pcsclite-cvs-commit
mailing list