Bug 1176698 - Use fallible allocator for attribute values in the HTML parser. r=wchen.

This commit is contained in:
Henri Sivonen
2015-08-25 18:05:46 +03:00
parent c02fb472a7
commit 4d0b61f3f6
15 changed files with 90 additions and 35 deletions

View File

@@ -6,6 +6,7 @@
#include "nsString.h"
#include "jArray.h"
#include "nsHtml5Portability.h"
#include "nsHtml5TreeBuilder.h"
nsIAtom*
nsHtml5Portability::newLocalNameFromBuffer(char16_t* buf, int32_t offset, int32_t length, nsHtml5AtomTable* interner)
@@ -16,9 +17,15 @@ nsHtml5Portability::newLocalNameFromBuffer(char16_t* buf, int32_t offset, int32_
}
nsString*
nsHtml5Portability::newStringFromBuffer(char16_t* buf, int32_t offset, int32_t length)
nsHtml5Portability::newStringFromBuffer(char16_t* buf, int32_t offset, int32_t length, nsHtml5TreeBuilder* treeBuilder)
{
return new nsString(buf + offset, length);
nsString* str = new nsString();
bool succeeded = str->Append(buf + offset, length, mozilla::fallible);
if (!succeeded) {
str->Assign(char16_t(0xFFFD));
treeBuilder->MarkAsBroken(NS_ERROR_OUT_OF_MEMORY);
}
return str;
}
nsString*