Commit 311f0df844 for ffmpeg
commit 311f0df844941a5b7778824f2e9baa34f041252a
Author: Michael Niedermayer <michael@niedermayer.cc>
Date: Thu Nov 12 01:57:34 2026 +0100
ffplay: set audio_st once the audio output is started
The display uses audio_tgt as soon as audio_st is set, and divided by
its 0 channels while the read thread was still opening the audio device.
Fixes: division by zero
Fixes: bgaX0SiJAybS
Regression since: c74f97bcd8
Found during the triage of a finding from the review of https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25375
Division by zero Replicated through UnModified FFmpeg with UBSAN
diff --git a/fftools/ffplay.c b/fftools/ffplay.c
index c7c6933a1b..00e64d255e 100644
--- a/fftools/ffplay.c
+++ b/fftools/ffplay.c
@@ -3067,16 +3067,17 @@ static int stream_component_open(VideoState *is, int stream_index)
goto fail;
is->audio_stream = stream_index;
- is->audio_st = ic->streams[stream_index];
if ((ret = decoder_init(&is->auddec, avctx, &is->audioq, is->continue_read_thread)) < 0)
goto fail;
if (is->ic->iformat->flags & AVFMT_NOTIMESTAMPS) {
- is->auddec.start_pts = is->audio_st->start_time;
- is->auddec.start_pts_tb = is->audio_st->time_base;
+ is->auddec.start_pts = ic->streams[stream_index]->start_time;
+ is->auddec.start_pts_tb = ic->streams[stream_index]->time_base;
}
if (!SDL_AtomicGet(&is->replacement) && (ret = audio_start(is)) < 0)
stream_component_close(is, stream_index);
+ else
+ is->audio_st = ic->streams[stream_index];
break;
case AVMEDIA_TYPE_VIDEO:
is->video_stream = stream_index;