From b27573a239b4da8fd8cf2bbc59d74a1a9b56a32b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20Michaj=C5=82ow?= Date: Sun, 26 Jul 2026 12:11:34 +0200 Subject: [PATCH] demux: fail probing when the stream cannot be rewound to the start Each probe attempt assumes it reads from position 0. If the rewind fails, the demuxer would silently misparse the stream from a wrong position. On non-seekable streams this may fail when the probe size > buffer size, which would cause us to drop the buffered data and not allow to rewind the stream. This can be improved in the future. --- demux/demux.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/demux/demux.c b/demux/demux.c index b63038b6c4..22540bbb8e 100644 --- a/demux/demux.c +++ b/demux/demux.c @@ -3436,8 +3436,12 @@ static struct demuxer *open_given_type(struct mpv_global *global, mp_dbg(log, "Trying demuxer: %s (force-level: %s)\n", desc->name, d_level(check)); - if (stream) - stream_seek(stream, 0); + if (stream && !stream_seek(stream, 0)) { + mp_err(log, "Failed to rewind stream to the start.\n"); + demuxer->stream = NULL; + demux_free(demuxer); + return NULL; + } in->d_thread->params = params; // temporary during open() int ret = demuxer->desc->open(in->d_thread, check);