From bae268cb8505bcc5bf4048cfd448168ad9bb0992 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Thu, 16 Nov 2023 15:14:16 +0100 Subject: [PATCH] Fix crash with subtitles for which we have no codec. --- src/lib/ffmpeg_decoder.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/lib/ffmpeg_decoder.cc b/src/lib/ffmpeg_decoder.cc index c3d32bc75..6e9d671a2 100644 --- a/src/lib/ffmpeg_decoder.cc +++ b/src/lib/ffmpeg_decoder.cc @@ -634,9 +634,14 @@ FFmpegDecoder::process_video_frame () void FFmpegDecoder::decode_and_process_subtitle_packet (AVPacket* packet) { + auto context = subtitle_codec_context(); + if (!context) { + return; + } + int got_subtitle; AVSubtitle sub; - if (avcodec_decode_subtitle2 (subtitle_codec_context(), &sub, &got_subtitle, packet) < 0 || !got_subtitle) { + if (avcodec_decode_subtitle2(context, &sub, &got_subtitle, packet) < 0 || !got_subtitle) { return; } -- 2.30.2