Bug 1237201 part 3 - Handle Vector OOM in StreamingLexer. r=njn

This commit is contained in:
Jan de Mooij 2016-01-14 15:19:21 +01:00
Родитель 98f91b82f9
Коммит 3c3f394c55
2 изменённых файлов: 7 добавлений и 3 удалений

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

@ -316,7 +316,9 @@ public:
size_t toRead = std::min(aLength, mTransition.Size() - mBuffer.length()); size_t toRead = std::min(aLength, mTransition.Size() - mBuffer.length());
mBuffer.append(aInput, toRead); if (!mBuffer.append(aInput, toRead)) {
return Some(TerminalState::FAILURE);
}
aInput += toRead; aInput += toRead;
aLength -= toRead; aLength -= toRead;
if (mBuffer.length() != mTransition.Size()) { if (mBuffer.length() != mTransition.Size()) {
@ -394,7 +396,9 @@ public:
if (!mBuffer.reserve(mTransition.Size())) { if (!mBuffer.reserve(mTransition.Size())) {
return Some(TerminalState::FAILURE); // Done due to allocation failure. return Some(TerminalState::FAILURE); // Done due to allocation failure.
} }
mBuffer.append(aInput, aLength); if (!mBuffer.append(aInput, aLength)) {
return Some(TerminalState::FAILURE);
}
return Nothing(); // Need more input. return Nothing(); // Need more input.
} }

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

@ -55,7 +55,7 @@ DoLexWithUnbuffered(TestState aState, const char* aData, size_t aLength,
return Transition::ToUnbuffered(TestState::TWO, TestState::UNBUFFERED, 3); return Transition::ToUnbuffered(TestState::TWO, TestState::UNBUFFERED, 3);
case TestState::UNBUFFERED: case TestState::UNBUFFERED:
EXPECT_TRUE(aLength <= 3); EXPECT_TRUE(aLength <= 3);
aUnbufferedVector.append(aData, aLength); EXPECT_TRUE(aUnbufferedVector.append(aData, aLength));
return Transition::ContinueUnbuffered(TestState::UNBUFFERED); return Transition::ContinueUnbuffered(TestState::UNBUFFERED);
case TestState::TWO: case TestState::TWO:
CheckData(aUnbufferedVector.begin(), aUnbufferedVector.length()); CheckData(aUnbufferedVector.begin(), aUnbufferedVector.length());