From 322d947a049f0d753935fa96d08e6aada0d0af23 Mon Sep 17 00:00:00 2001 From: Tobias Brunner Date: Mon, 13 Jul 2026 17:14:12 +0200 Subject: [PATCH] eap-sim-pcsc: Properly release context if determining list of readers fails Fixes: 80dca77a50ec ("Added SIM card backend based on pcsc-lite") --- src/libcharon/plugins/eap_sim_pcsc/eap_sim_pcsc_card.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libcharon/plugins/eap_sim_pcsc/eap_sim_pcsc_card.c b/src/libcharon/plugins/eap_sim_pcsc/eap_sim_pcsc_card.c index 141b123ae..574f37f80 100644 --- a/src/libcharon/plugins/eap_sim_pcsc/eap_sim_pcsc_card.c +++ b/src/libcharon/plugins/eap_sim_pcsc/eap_sim_pcsc_card.c @@ -95,7 +95,7 @@ METHOD(simaka_card_t, get_triplet, bool, LONG rv; SCARDCONTEXT hContext; DWORD dwReaders; - LPSTR mszReaders; + LPSTR mszReaders = NULL; char *cur_reader; char full_nai[128]; SCARDHANDLE hCard; @@ -116,7 +116,7 @@ METHOD(simaka_card_t, get_triplet, bool, if (rv != SCARD_S_SUCCESS) { DBG1(DBG_IKE, "SCardListReaders: %s", pcsc_stringify_error(rv)); - return FALSE; + goto failed; } mszReaders = malloc(sizeof(char)*dwReaders); @@ -124,8 +124,7 @@ METHOD(simaka_card_t, get_triplet, bool, if (rv != SCARD_S_SUCCESS) { DBG1(DBG_IKE, "SCardListReaders: %s", pcsc_stringify_error(rv)); - free(mszReaders); - return FALSE; + goto failed; } /* 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 */ } +failed: /* Make sure we end any previous transaction and disconnect card */ switch (hCard_status) {