Bug 1144107 - Part 4: Prevent assert when hitting EOS. r=kentuckyfriedtakahe, a=abillings
☠☠ backed out by e699a62fdcbc ☠ ☠
authorJean-Yves Avenard <jyavenard@mozilla.com>
Wed, 15 Jul 2015 09:14:10 -0400
changeset 275348 716d122771c600b4bfc443ea7e1725ad5cc200d7
parent 275347 20c4fa40bc79c7fe8c9e20d3460a4e94d7ce898b
child 275349 7b298d7ccd2a4190168321524b1fd9f047fd4589
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);