mirror of
https://github.com/mpv-player/mpv
synced 2024-12-24 07:33:46 +01:00
demuxer: fix crash with demux_rawvideo
rawvideo is a rather primitive demuxer that doesn't implement track switching. The problem was that during track switching the demuxer implementations normally set the stream IDs in order to do the switch, and since rawvideo obviously didn't do that, so the current stream in ds->sh / demuxer->video->sh was set to NULL. (The frontend always assumes track switching is successful, which is a reasonable assumption - failing due to missing video codecs etc. is in separate codepaths.) Later, demux_rawvideo_fill_buffer() in demux_rawvideo.c tried to dereference the NULL stream and crashed. Other trivial single-stream demuxers worked fine, because they didn't try to access ds->sh.
This commit is contained in:
parent
397eb9364b
commit
b2ba73c7b6
@ -1223,9 +1223,13 @@ void demuxer_switch_track(struct demuxer *demuxer, enum stream_type type,
|
||||
assert(!stream || stream->type == type);
|
||||
int index = stream ? stream->tid : -2;
|
||||
if (type == STREAM_AUDIO) {
|
||||
demux_control(demuxer, DEMUXER_CTRL_SWITCH_AUDIO, &index);
|
||||
if (demux_control(demuxer, DEMUXER_CTRL_SWITCH_AUDIO, &index)
|
||||
== DEMUXER_CTRL_NOTIMPL)
|
||||
demuxer->audio->id = index;
|
||||
} else if (type == STREAM_VIDEO) {
|
||||
demux_control(demuxer, DEMUXER_CTRL_SWITCH_VIDEO, &index);
|
||||
if (demux_control(demuxer, DEMUXER_CTRL_SWITCH_VIDEO, &index)
|
||||
== DEMUXER_CTRL_NOTIMPL)
|
||||
demuxer->video->id = index;
|
||||
} else if (type == STREAM_SUB) {
|
||||
int index2 = stream ? stream->stream_index : -2;
|
||||
if (demuxer->ds[type]->id != index2)
|
||||
|
Loading…
Reference in New Issue
Block a user