[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

@ -7,6 +7,15 @@
#include "jArray.h"
#include "nsHtml5Portability.h"
#include "nsHtml5TreeBuilder.h"
#include "mozilla/CheckedInt.h"
int32_t nsHtml5Portability::checkedAdd(int32_t a, int32_t b) {
mozilla::CheckedInt<int32_t> sum(a);
sum += b;
MOZ_RELEASE_ASSERT(sum.isValid(),
"HTML input too large for signed 32-bit integer.");
return sum.value();
}
nsIAtom*
nsHtml5Portability::newLocalNameFromBuffer(char16_t* buf, int32_t offset, int32_t length, nsHtml5AtomTable* interner)