diff options
-rw-r--r-- | media/filters/ffmpeg_demuxer.cc | 3 | ||||
-rw-r--r-- | media/filters/ffmpeg_demuxer_unittest.cc | 3 |
2 files changed, 5 insertions, 1 deletions
diff --git a/media/filters/ffmpeg_demuxer.cc b/media/filters/ffmpeg_demuxer.cc index af0d71e..4c26a8a 100644 --- a/media/filters/ffmpeg_demuxer.cc +++ b/media/filters/ffmpeg_demuxer.cc @@ -328,7 +328,8 @@ bool FFmpegDemuxer::SetPosition(int64 position) { DCHECK(data_source_); int64 file_size; - if (!data_source_->GetSize(&file_size) || position >= file_size) + if (!data_source_->GetSize(&file_size) || position >= file_size || + position < 0) return false; read_position_ = position; diff --git a/media/filters/ffmpeg_demuxer_unittest.cc b/media/filters/ffmpeg_demuxer_unittest.cc index 078f54b..2bea53a 100644 --- a/media/filters/ffmpeg_demuxer_unittest.cc +++ b/media/filters/ffmpeg_demuxer_unittest.cc @@ -769,6 +769,8 @@ TEST_F(FFmpegDemuxerTest, ProtocolGetSetPosition) { .WillOnce(DoAll(SetArgumentPointee<0>(1024), Return(true))); EXPECT_CALL(*data_source_, GetSize(_)) .WillOnce(DoAll(SetArgumentPointee<0>(1024), Return(true))); + EXPECT_CALL(*data_source_, GetSize(_)) + .WillOnce(DoAll(SetArgumentPointee<0>(1024), Return(true))); int64 position; EXPECT_TRUE(demuxer_->GetPosition(&position)); @@ -776,6 +778,7 @@ TEST_F(FFmpegDemuxerTest, ProtocolGetSetPosition) { EXPECT_TRUE(demuxer_->SetPosition(512)); EXPECT_FALSE(demuxer_->SetPosition(2048)); + EXPECT_FALSE(demuxer_->SetPosition(-1)); EXPECT_TRUE(demuxer_->GetPosition(&position)); EXPECT_EQ(512, position); } |