From d231cd06e674a219d263fb3d070138de58357c82 Mon Sep 17 00:00:00 2001 From: Martin Pulec Date: Mon, 24 Apr 2023 12:37:16 +0200 Subject: [PATCH] video_display: handle err if audio req but notavail If video_display doesn't provide callbacks for audio, but user still requests something like: uv -t testcard -s testcard -d gl -r embedded UltraGrid crashed on NULL pointer dereferencing. That mistake can quite easily happen, so display rather user-friendly message than just crashing. --- src/video_display.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/video_display.c b/src/video_display.c index c2d4966a2..024d06ebc 100644 --- a/src/video_display.c +++ b/src/video_display.c @@ -574,6 +574,11 @@ void display_put_audio_frame(struct display *d, const struct audio_frame *frame) int display_reconfigure_audio(struct display *d, int quant_samples, int channels, int sample_rate) { assert(d->magic == DISPLAY_MAGIC); + if (!d->funcs->reconfigure_audio) { + log_msg(LOG_LEVEL_FATAL, MOD_NAME "Selected display '%s' doesn't support audio!\n", d->display_name); + exit_uv(EXIT_FAIL_USAGE); + return FALSE; + } return d->funcs->reconfigure_audio(d->state, quant_samples, channels, sample_rate); }