Bug 1101247 - Handle empty top-level mp4 boxes in MoofParser. r=ajones
authorMatt Woodrow <mwoodrow@mozilla.com>
Thu, 20 Nov 2014 15:00:35 +1300
changeset 216811 bbc87380fd6a1ef4c16cf619e8ba56a97241ba1e
parent 216810 b6946c2e8558a64884e02e9564283fce8f67df30
child 216812 deb0b389efa7a82812c04a73657aeecf1ff5d663
push id27864
push usercbook@mozilla.com
push dateFri, 21 Nov 2014 11:57:14 +0000
treeherdermozilla-central@23ca43337c3f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersajones
bugs1101247
milestone36.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1101247 - Handle empty top-level mp4 boxes in MoofParser. r=ajones
media/libstagefright/binding/Box.cpp
media/libstagefright/binding/include/mp4_demuxer/Box.h
--- a/media/libstagefright/binding/Box.cpp
+++ b/media/libstagefright/binding/Box.cpp
@@ -54,36 +54,43 @@ Box::Box(BoxContext* aContext, uint64_t 
     }
     size = BigEndian::readUint64(bigLength);
     mChildOffset = bigLengthRange.mEnd;
   } else {
     mChildOffset = headerRange.mEnd;
   }
 
   MediaByteRange boxRange(aOffset, aOffset + size);
-  if (mChildOffset >= boxRange.mEnd ||
+  if (mChildOffset > boxRange.mEnd ||
       (mParent && !mParent->mRange.Contains(boxRange)) ||
       !byteRange->Contains(boxRange)) {
     return;
   }
-  mRange = MediaByteRange(aOffset, aOffset + size);
+  mRange = boxRange;
   mType = BigEndian::readUint32(&header[4]);
 }
 
+Box::Box()
+  : mContext(nullptr), mType(0)
+{}
+
 Box
 Box::Next() const
 {
   MOZ_ASSERT(IsAvailable());
   return Box(mContext, mRange.mEnd, mParent);
 }
 
 Box
 Box::FirstChild() const
 {
   MOZ_ASSERT(IsAvailable());
+  if (mChildOffset == mRange.mEnd) {
+    return Box();
+  }
   return Box(mContext, mChildOffset, this);
 }
 
 void
 Box::Read(nsTArray<uint8_t>* aDest)
 {
   aDest->SetLength(mRange.mEnd - mChildOffset);
   size_t bytes;
--- a/media/libstagefright/binding/include/mp4_demuxer/Box.h
+++ b/media/libstagefright/binding/include/mp4_demuxer/Box.h
@@ -30,16 +30,17 @@ public:
   Stream* mSource;
   const nsTArray<MediaByteRange>& mByteRanges;
 };
 
 class Box
 {
 public:
   Box(BoxContext* aContext, uint64_t aOffset, const Box* aParent = nullptr);
+  Box();
 
   bool IsAvailable() const { return !mRange.IsNull(); }
   uint64_t Offset() const { return mRange.mStart; }
   uint64_t Length() const { return mRange.mEnd - mRange.mStart; }
   uint64_t NextOffset() const { return mRange.mEnd; }
   const MediaByteRange& Range() const { return mRange; }
 
   const Box* Parent() const { return mParent; }