[html parser] Check for integer overflow when computing new buffer sizes.

This commit is contained in:
Moonchild 2021-02-24 09:57:24 +00:00 committed by roytam1
commit 5934c74a3f
7 changed files with 36 additions and 13 deletions

View file

@ -743,7 +743,7 @@ void
nsHtml5MetaScanner::addToBuffer(int32_t c)
{
if (strBufLen == strBuf.length) {
jArray<char16_t,int32_t> newBuf = jArray<char16_t,int32_t>::newJArray(strBuf.length + (strBuf.length << 1));
jArray<char16_t,int32_t> newBuf = jArray<char16_t,int32_t>::newJArray(nsHtml5Portability::checkedAdd(strBuf.length, (strBuf.length << 1)));
nsHtml5ArrayCopy::arraycopy(strBuf, newBuf, strBuf.length);
strBuf = newBuf;
}