Commit 27fc778a authored by Thomas Guilbert's avatar Thomas Guilbert Committed by Commit Bot

Fix clusterfuzz DCHECK

Calling avformat_find_stream_info can change the number of streams in
the AVFormatContext. This means that an index that we thought was
pointing towards an audio stream can now be referring to a video stream
after the call.

This CL fixes the issue by finding a new audio stream after calling
avformat_find_stream_info.

Bug: 1025964
Change-Id: I81f661412dcb108865925a37cb254db89938d00f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1953395
Commit-Queue: Thomas Guilbert <tguilbert@chromium.org>
Auto-Submit: Thomas Guilbert <tguilbert@chromium.org>
Reviewed-by: default avatarDale Curtis <dalecurtis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#722724}
parent 1e5d89d0
...@@ -51,7 +51,15 @@ bool AudioFileReader::OpenDemuxer() { ...@@ -51,7 +51,15 @@ bool AudioFileReader::OpenDemuxer() {
return false; return false;
} }
// Find the first audio stream, if any. const int result = avformat_find_stream_info(format_context, NULL);
if (result < 0) {
DLOG(WARNING)
<< "AudioFileReader::Open() : error in avformat_find_stream_info()";
return false;
}
// Calling avformat_find_stream_info can uncover new streams. We wait till now
// to find the first audio stream, if any.
codec_context_.reset(); codec_context_.reset();
bool found_stream = false; bool found_stream = false;
for (size_t i = 0; i < format_context->nb_streams; ++i) { for (size_t i = 0; i < format_context->nb_streams; ++i) {
...@@ -66,13 +74,6 @@ bool AudioFileReader::OpenDemuxer() { ...@@ -66,13 +74,6 @@ bool AudioFileReader::OpenDemuxer() {
if (!found_stream) if (!found_stream)
return false; return false;
const int result = avformat_find_stream_info(format_context, NULL);
if (result < 0) {
DLOG(WARNING)
<< "AudioFileReader::Open() : error in avformat_find_stream_info()";
return false;
}
// Get the codec context. // Get the codec context.
codec_context_ = codec_context_ =
AVStreamToAVCodecContext(format_context->streams[stream_index_]); AVStreamToAVCodecContext(format_context->streams[stream_index_]);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment