Skip to content

Commit b27573a

Browse files
committed
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.
1 parent 762c599 commit b27573a

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

demux/demux.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3436,8 +3436,12 @@ static struct demuxer *open_given_type(struct mpv_global *global,
34363436
mp_dbg(log, "Trying demuxer: %s (force-level: %s)\n",
34373437
desc->name, d_level(check));
34383438

3439-
if (stream)
3440-
stream_seek(stream, 0);
3439+
if (stream && !stream_seek(stream, 0)) {
3440+
mp_err(log, "Failed to rewind stream to the start.\n");
3441+
demuxer->stream = NULL;
3442+
demux_free(demuxer);
3443+
return NULL;
3444+
}
34413445

34423446
in->d_thread->params = params; // temporary during open()
34433447
int ret = demuxer->desc->open(in->d_thread, check);

0 commit comments

Comments
 (0)