Bug 1128939: Part2. Make sure we limit read to buffer size and handle error nicely. r=k17e

This commit is contained in:
Jean-Yves Avenard 2015-02-12 18:52:12 +11:00
Родитель 3099b941be
Коммит 4132c3064d
1 изменённых файлов: 16 добавлений и 2 удалений

Просмотреть файл

@ -3497,7 +3497,14 @@ status_t MPEG4Source::read(
// Each NAL unit is split up into its constituent fragments and
// each one of them returned in its own buffer.
CHECK(mBuffer->range_length() >= mNALLengthSize);
if (mBuffer->range_length() < mNALLengthSize) {
ALOGE("incomplete NAL unit.");
mBuffer->release();
mBuffer = NULL;
return ERROR_MALFORMED;
}
const uint8_t *src =
(const uint8_t *)mBuffer->data() + mBuffer->range_offset();
@ -3859,7 +3866,14 @@ status_t MPEG4Source::fragmentedRead(
// Each NAL unit is split up into its constituent fragments and
// each one of them returned in its own buffer.
CHECK(mBuffer->range_length() >= mNALLengthSize);
if (mBuffer->range_length() < mNALLengthSize) {
ALOGE("incomplete NAL unit.");
mBuffer->release();
mBuffer = NULL;
return ERROR_MALFORMED;
}
const uint8_t *src =
(const uint8_t *)mBuffer->data() + mBuffer->range_offset();