diff --git a/include/freerdp/utils/smartcard_call.h b/include/freerdp/utils/smartcard_call.h index 2589cadab..166b737b5 100644 --- a/include/freerdp/utils/smartcard_call.h +++ b/include/freerdp/utils/smartcard_call.h @@ -44,6 +44,13 @@ extern "C" WINPR_ATTR_NODISCARD FREERDP_API scard_call_context* smartcard_call_context_new(const rdpSettings* settings); + /** @brief send a stop signal (or reset it if \b reset is \b TRUE) to a \ref scard_call_context + * + * @param ctx The context to send the signal to. Must not be \b nullptr + * @param reset Set or reset the signal + * + * @return \b TRUE for success, \b FALSE otherwise. + */ FREERDP_API BOOL smartcard_call_context_signal_stop(scard_call_context* ctx, BOOL reset); WINPR_ATTR_NODISCARD diff --git a/libfreerdp/utils/smartcard_call.c b/libfreerdp/utils/smartcard_call.c index b1c3ae7af..7c1d966b6 100644 --- a/libfreerdp/utils/smartcard_call.c +++ b/libfreerdp/utils/smartcard_call.c @@ -2051,7 +2051,8 @@ BOOL smartcard_call_release_context(scard_call_context* ctx, SCARDCONTEXT hConte BOOL smartcard_call_cancel_all_context(scard_call_context* ctx) { - WINPR_ASSERT(ctx); + if (!ctx) + return FALSE; smartcard_call_context_signal_stop(ctx, FALSE); HashTable_Clear(ctx->rgSCardContextList); @@ -2094,6 +2095,7 @@ BOOL smartcard_call_is_configured(scard_call_context* ctx) BOOL smartcard_call_context_signal_stop(scard_call_context* ctx, BOOL reset) { WINPR_ASSERT(ctx); + if (!ctx->stopEvent) return TRUE; diff --git a/server/proxy/channels/pf_channel_smartcard.c b/server/proxy/channels/pf_channel_smartcard.c index 1b9a60a62..9dc1ee269 100644 --- a/server/proxy/channels/pf_channel_smartcard.c +++ b/server/proxy/channels/pf_channel_smartcard.c @@ -271,7 +271,8 @@ BOOL pf_channel_smartcard_server_handle(WINPR_ATTR_UNUSED pServerContext* ps, static void channel_stop_and_wait(pf_channel_client_context* scard, BOOL reset) { WINPR_ASSERT(scard); - smartcard_call_context_signal_stop(scard->callctx, FALSE); + if (scard->callctx) + smartcard_call_context_signal_stop(scard->callctx, FALSE); while (ArrayList_Count(scard->workObjects) > 0) { @@ -281,7 +282,8 @@ static void channel_stop_and_wait(pf_channel_client_context* scard, BOOL reset) WaitForThreadpoolWorkCallbacks(work, TRUE); } - smartcard_call_context_signal_stop(scard->callctx, reset); + if (scard->callctx) + smartcard_call_context_signal_stop(scard->callctx, reset); } static void pf_channel_scard_client_context_free(InterceptContextMapEntry* base)