eap-sim-pcsc: Properly release context if determining list of readers fails
Fixes: 80dca77a50 ("Added SIM card backend based on pcsc-lite")
This commit is contained in:
@@ -95,7 +95,7 @@ METHOD(simaka_card_t, get_triplet, bool,
|
|||||||
LONG rv;
|
LONG rv;
|
||||||
SCARDCONTEXT hContext;
|
SCARDCONTEXT hContext;
|
||||||
DWORD dwReaders;
|
DWORD dwReaders;
|
||||||
LPSTR mszReaders;
|
LPSTR mszReaders = NULL;
|
||||||
char *cur_reader;
|
char *cur_reader;
|
||||||
char full_nai[128];
|
char full_nai[128];
|
||||||
SCARDHANDLE hCard;
|
SCARDHANDLE hCard;
|
||||||
@@ -116,7 +116,7 @@ METHOD(simaka_card_t, get_triplet, bool,
|
|||||||
if (rv != SCARD_S_SUCCESS)
|
if (rv != SCARD_S_SUCCESS)
|
||||||
{
|
{
|
||||||
DBG1(DBG_IKE, "SCardListReaders: %s", pcsc_stringify_error(rv));
|
DBG1(DBG_IKE, "SCardListReaders: %s", pcsc_stringify_error(rv));
|
||||||
return FALSE;
|
goto failed;
|
||||||
}
|
}
|
||||||
mszReaders = malloc(sizeof(char)*dwReaders);
|
mszReaders = malloc(sizeof(char)*dwReaders);
|
||||||
|
|
||||||
@@ -124,8 +124,7 @@ METHOD(simaka_card_t, get_triplet, bool,
|
|||||||
if (rv != SCARD_S_SUCCESS)
|
if (rv != SCARD_S_SUCCESS)
|
||||||
{
|
{
|
||||||
DBG1(DBG_IKE, "SCardListReaders: %s", pcsc_stringify_error(rv));
|
DBG1(DBG_IKE, "SCardListReaders: %s", pcsc_stringify_error(rv));
|
||||||
free(mszReaders);
|
goto failed;
|
||||||
return FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* mszReaders is a multi-string of readers, separated by '\0' and
|
/* mszReaders is a multi-string of readers, separated by '\0' and
|
||||||
@@ -334,6 +333,7 @@ METHOD(simaka_card_t, get_triplet, bool,
|
|||||||
* beginning of this loop or after this loop */
|
* beginning of this loop or after this loop */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
failed:
|
||||||
/* Make sure we end any previous transaction and disconnect card */
|
/* Make sure we end any previous transaction and disconnect card */
|
||||||
switch (hCard_status)
|
switch (hCard_status)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user