Changeset 3535
- Timestamp:
- 07/02/08 11:55:32 (3 months ago)
- Files:
-
- 1 modified
-
trunk/src/libopensc/reader-pcsc.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/libopensc/reader-pcsc.c
r3520 r3535 826 826 827 827 out: 828 if (ret != SC_SUCCESS) { 829 if (gpriv->pcsc_ctx != 0) 828 if (gpriv != NULL) { 829 if (gpriv->dlhandle != NULL) 830 lt_dlclose(gpriv->dlhandle); 831 free(gpriv); 832 } 833 834 return ret; 835 } 836 837 static int pcsc_finish(sc_context_t *ctx, void *prv_data) 838 { 839 struct pcsc_global_private_data *gpriv = (struct pcsc_global_private_data *) prv_data; 840 841 if (gpriv) { 842 if (gpriv->pcsc_ctx != -1) 830 843 gpriv->SCardReleaseContext(gpriv->pcsc_ctx); 831 844 if (gpriv->dlhandle != NULL) 832 845 lt_dlclose(gpriv->dlhandle); 833 if (gpriv != NULL) 834 free(gpriv); 835 } 836 837 return 0; 838 } 839 840 static int pcsc_finish(sc_context_t *ctx, void *prv_data) 841 { 842 struct pcsc_global_private_data *priv = (struct pcsc_global_private_data *) prv_data; 843 844 if (priv) { 845 priv->SCardReleaseContext(priv->pcsc_ctx); 846 lt_dlclose(priv->dlhandle); 847 free(priv); 846 free(gpriv); 848 847 } 849 848 … … 860 859 int ret = SC_ERROR_INTERNAL; 861 860 862 if (! prv_data) {861 if (!gpriv) { 863 862 ret = SC_ERROR_NO_READERS_FOUND; 864 863 goto out; … … 866 865 867 866 do { 868 rv = gpriv->SCardListReaders(gpriv->pcsc_ctx, NULL, NULL, 869 (LPDWORD) &reader_buf_size); 867 if (gpriv->pcsc_ctx == -1) { 868 /* 869 * Cannot call SCardListReaders with -1 870 * context as in Windows ERROR_INVALID_HANDLE 871 * is returned instead of SCARD_E_INVALID_HANDLE 872 */ 873 rv = SCARD_E_INVALID_HANDLE; 874 } 875 else { 876 rv = gpriv->SCardListReaders(gpriv->pcsc_ctx, NULL, NULL, 877 (LPDWORD) &reader_buf_size); 878 } 870 879 if (rv != SCARD_S_SUCCESS) { 871 880 if (rv != SCARD_E_INVALID_HANDLE) {
