Skip to content

Commit

Permalink
Bug 1187076 - Warn at end of SPS buffers. r=jya
Browse files Browse the repository at this point in the history
Previously we asserted if we tried to read past the end
of a buffer in parsing H.264 SPS headers. This only affected
debug builds, but the failures were reported as crashes in
automated testing.

Therefore, commute the assert to a warning and silently accept
bad data of this type. The read is safe with the first assert
removed because of the subsequent check, and a similar one in
the parent class.
  • Loading branch information
rillian committed Sep 9, 2015
1 parent 5065eb9 commit bd0011b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions media/libstagefright/binding/H264.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ class BitReader

uint32_t ReadBits(size_t aNum)
{
MOZ_ASSERT(mBitReader.numBitsLeft());
MOZ_ASSERT(aNum <= 32);
if (mBitReader.numBitsLeft() < aNum) {
return 0;
Expand All @@ -48,7 +47,10 @@ class BitReader
i++;
}
if (i == 32) {
MOZ_ASSERT(false);
// This can happen if the data is invalid, or if it's
// short, since ReadBit() will return 0 when it runs
// off the end of the buffer.
NS_WARNING("Invalid H.264 data");
return 0;
}
uint32_t r = ReadBits(i);
Expand Down

0 comments on commit bd0011b

Please sign in to comment.