From 4b60f0651cf5da63834b960adf9c4b22e499e870 Mon Sep 17 00:00:00 2001 From: akallabeth Date: Mon, 23 Sep 2024 12:00:02 +0200 Subject: [PATCH] [channels] Fix PulseAudio assertions/NULL checks --- channels/audin/client/pulse/audin_pulse.c | 4 +++- channels/rdpsnd/client/pulse/rdpsnd_pulse.c | 2 +- channels/tsmf/client/pulse/tsmf_pulse.c | 2 ++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/channels/audin/client/pulse/audin_pulse.c b/channels/audin/client/pulse/audin_pulse.c index fb9d17a70..8977c420b 100644 --- a/channels/audin/client/pulse/audin_pulse.c +++ b/channels/audin/client/pulse/audin_pulse.c @@ -292,6 +292,8 @@ static UINT audin_pulse_set_format(IAudinDevice* device, const AUDIO_FORMAT* for static void audin_pulse_stream_state_callback(pa_stream* stream, void* userdata) { AudinPulseDevice* pulse = (AudinPulseDevice*)userdata; + WINPR_ASSERT(pulse); + pa_stream_state_t state = pa_stream_get_state(stream); WLog_Print(pulse->log, WLOG_DEBUG, "stream state %s", pulse_stream_state_string(state)); @@ -408,7 +410,7 @@ static UINT audin_pulse_open(IAudinDevice* device, AudinReceive receive, void* u return pa_context_errno(pulse->context); } - for (;;) + while (pulse->stream) { state = pa_stream_get_state(pulse->stream); diff --git a/channels/rdpsnd/client/pulse/rdpsnd_pulse.c b/channels/rdpsnd/client/pulse/rdpsnd_pulse.c index caf0a86ea..957948dff 100644 --- a/channels/rdpsnd/client/pulse/rdpsnd_pulse.c +++ b/channels/rdpsnd/client/pulse/rdpsnd_pulse.c @@ -414,7 +414,7 @@ static BOOL rdpsnd_pulse_open_stream(rdpsndDevicePlugin* device) return FALSE; } - for (;;) + while (pulse->stream) { state = pa_stream_get_state(pulse->stream); diff --git a/channels/tsmf/client/pulse/tsmf_pulse.c b/channels/tsmf/client/pulse/tsmf_pulse.c index 34a9fd55a..d580a243a 100644 --- a/channels/tsmf/client/pulse/tsmf_pulse.c +++ b/channels/tsmf/client/pulse/tsmf_pulse.c @@ -176,6 +176,8 @@ static void tsmf_pulse_wait_for_operation(TSMFPulseAudioDevice* pulse, pa_operat static void tsmf_pulse_stream_state_callback(pa_stream* stream, void* userdata) { TSMFPulseAudioDevice* pulse = (TSMFPulseAudioDevice*)userdata; + WINPR_ASSERT(pulse); + pa_stream_state_t state = pa_stream_get_state(stream); switch (state)