summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorcevans@chromium.org <cevans@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-03 18:27:40 +0000
committercevans@chromium.org <cevans@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-03 18:27:40 +0000
commitc87a1361b7f037393beaf6015efe4baa672a2a35 (patch)
treed1ac97e956eaced38673961a82104ab1dc42e115 /media
parent48f0ce4e0243f8a5f293c6dfeccf9ef4c28f0dc7 (diff)
downloadchromium_src-c87a1361b7f037393beaf6015efe4baa672a2a35.zip
chromium_src-c87a1361b7f037393beaf6015efe4baa672a2a35.tar.gz
chromium_src-c87a1361b7f037393beaf6015efe4baa672a2a35.tar.bz2
Do not permit a seek to a negative position. This was already an error
condition (in the FFmpeg glue code) but the position would be left set to negative. If the API consumer ignored the error code for the seek and then attempted a read, that might be a bad state. I am fixing this to avoid any risk of this upsetting the stream read code. FFmpeg would seem to commit this sort of API abuse. BUG=NONE TEST=FFmpegDemuxerTest.ProtocolGetSetPosition Review URL: http://codereview.chromium.org/201002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25334 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media')
-rw-r--r--media/filters/ffmpeg_demuxer.cc3
-rw-r--r--media/filters/ffmpeg_demuxer_unittest.cc3
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);
}