Skip to content

Commit

Permalink
Bug 1101247 - Handle empty top-level mp4 boxes in MoofParser. r=ajones
Browse files Browse the repository at this point in the history
  • Loading branch information
mattwoodrow committed Nov 20, 2014
1 parent a6d2382 commit a6aadad
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
11 changes: 9 additions & 2 deletions media/libstagefright/binding/Box.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,19 @@ Box::Box(BoxContext* aContext, uint64_t aOffset, const Box* aParent)
}

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
{
Expand All @@ -79,6 +83,9 @@ Box
Box::FirstChild() const
{
MOZ_ASSERT(IsAvailable());
if (mChildOffset == mRange.mEnd) {
return Box();
}
return Box(mContext, mChildOffset, this);
}

Expand Down
1 change: 1 addition & 0 deletions media/libstagefright/binding/include/mp4_demuxer/Box.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ 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; }
Expand Down

0 comments on commit a6aadad

Please sign in to comment.