Bug 1261744 - Add two missing null checks for nsStringBuffer::Alloc(). r=erahm.
This commit is contained in:
@@ -14,7 +14,13 @@ nsHtml5Atom::nsHtml5Atom(const nsAString& aString)
|
||||
if (buf) {
|
||||
mString = static_cast<char16_t*>(buf->Data());
|
||||
} else {
|
||||
buf = nsStringBuffer::Alloc((mLength + 1) * sizeof(char16_t));
|
||||
const size_t size = (mLength + 1) * sizeof(char16_t);
|
||||
buf = nsStringBuffer::Alloc(size);
|
||||
if (MOZ_UNLIKELY(!buf)) {
|
||||
// We OOM because atom allocations should be small and it's hard to
|
||||
// handle them more gracefully in a constructor.
|
||||
NS_ABORT_OOM(size);
|
||||
}
|
||||
mString = static_cast<char16_t*>(buf->Data());
|
||||
CopyUnicodeTo(aString, 0, mString, mLength);
|
||||
mString[mLength] = char16_t(0);
|
||||
|
||||
Reference in New Issue
Block a user