Bug 1236227, don't OOM in TextDecoder, r=baku

This commit is contained in:
Olli Pettay 2016-01-05 15:48:47 +02:00
parent c400438df8
commit 2611069ac0

View File

@ -75,7 +75,11 @@ TextDecoder::Decode(const char* aInput, const int32_t aLength,
rv = mDecoder->Convert(aInput, &length, buf, &outLen);
MOZ_ASSERT(mFatal || rv != NS_ERROR_ILLEGAL_INPUT);
buf[outLen] = 0;
aOutDecodedString.Append(buf, outLen);
if (!aOutDecodedString.Append(buf, outLen, fallible)) {
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
return;
}
// If the internal streaming flag of the decoder object is not set,
// then reset the encoding algorithm state to the default values