diff options
author | wm4 <wm4@nowhere> | 2012-09-23 14:59:36 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2012-09-23 15:15:43 +0200 |
commit | b2ba73c7b62f24326d62dd0a263942038146afaa (patch) | |
tree | 785f7b1c5308a6724eca7a6dc214da168b39b786 | |
parent | 397eb9364b83ede4c4f82f52dff8ed1ecb414338 (diff) | |
download | mpv-b2ba73c7b62f24326d62dd0a263942038146afaa.tar.bz2 mpv-b2ba73c7b62f24326d62dd0a263942038146afaa.tar.xz |
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.
-rw-r--r-- | libmpdemux/demuxer.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/libmpdemux/demuxer.c b/libmpdemux/demuxer.c index 2706f3a9ea..55b5d0f1c0 100644 --- a/libmpdemux/demuxer.c +++ b/libmpdemux/demuxer.c @@ -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) |