Bug 1144107 - Part 4: Prevent assert when hitting EOS. r=kentuckyfriedtakahe, a=abillings
authorJean-Yves Avenard <jyavenard@mozilla.com>
Wed, 15 Jul 2015 09:14:10 -0400
changeset 275352 5331e255aab27d8638d9daabe8a5c3328dde54b0
parent 275351 e699a62fdcbc2f37c91551803539ea7676d7e783
child 275353 1015755a8a4af5da30bd440392035b1591efcf23
push id863
push userraliiev@mozilla.com
push dateMon, 03 Aug 2015 13:22:43 +0000
treeherdermozilla-release@f6321b14228d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskentuckyfriedtakahe, abillings
bugs1144107
milestone40.0
Bug 1144107 - Part 4: Prevent assert when hitting EOS. r=kentuckyfriedtakahe, a=abillings this would occur if we attempt to read exactly the end of the array.
media/libstagefright/binding/BufferStream.cpp
--- a/media/libstagefright/binding/BufferStream.cpp
+++ b/media/libstagefright/binding/BufferStream.cpp
@@ -19,17 +19,17 @@ BufferStream::BufferStream()
 BufferStream::ReadAt(int64_t aOffset, void* aData, size_t aLength,
                      size_t* aBytesRead)
 {
   if (aOffset < mStartOffset || aOffset > mStartOffset + mData.Length()) {
     return false;
   }
   *aBytesRead =
     std::min(aLength, size_t(mStartOffset + mData.Length() - aOffset));
-  memcpy(aData, &mData[aOffset - mStartOffset], *aBytesRead);
+  memcpy(aData, mData.Elements() + aOffset - mStartOffset, *aBytesRead);
   return true;
 }
 
 /*virtual*/ bool
 BufferStream::CachedReadAt(int64_t aOffset, void* aData, size_t aLength,
                            size_t* aBytesRead)
 {
   return ReadAt(aOffset, aData, aLength, aBytesRead);