зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1237201 part 3 - Handle Vector OOM in StreamingLexer. r=njn
This commit is contained in:
Родитель
98f91b82f9
Коммит
3c3f394c55
|
@ -316,7 +316,9 @@ public:
|
|||
|
||||
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;
|
||||
aLength -= toRead;
|
||||
if (mBuffer.length() != mTransition.Size()) {
|
||||
|
@ -394,7 +396,9 @@ public:
|
|||
if (!mBuffer.reserve(mTransition.Size())) {
|
||||
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.
|
||||
}
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ DoLexWithUnbuffered(TestState aState, const char* aData, size_t aLength,
|
|||
return Transition::ToUnbuffered(TestState::TWO, TestState::UNBUFFERED, 3);
|
||||
case TestState::UNBUFFERED:
|
||||
EXPECT_TRUE(aLength <= 3);
|
||||
aUnbufferedVector.append(aData, aLength);
|
||||
EXPECT_TRUE(aUnbufferedVector.append(aData, aLength));
|
||||
return Transition::ContinueUnbuffered(TestState::UNBUFFERED);
|
||||
case TestState::TWO:
|
||||
CheckData(aUnbufferedVector.begin(), aUnbufferedVector.length());
|
||||
|
|
Загрузка…
Ссылка в новой задаче