Bug 950076 - Use the return value of GetNodeTextContent for OOM checks. r=jst

This commit is contained in:
Alessio Placitelli 2014-03-20 20:51:16 +01:00
parent ccd66ec5c9
commit 93c7f6ceef
15 changed files with 55 additions and 19 deletions

View File

@ -1067,7 +1067,8 @@ FragmentOrElement::RemoveChildAt(uint32_t aIndex, bool aNotify)
void
FragmentOrElement::GetTextContentInternal(nsAString& aTextContent)
{
nsContentUtils::GetNodeTextContent(this, true, aTextContent);
if(!nsContentUtils::GetNodeTextContent(this, true, aTextContent))
NS_RUNTIMEABORT("OOM");
}
void

View File

@ -6622,7 +6622,8 @@ nsDocument::GetTitleFromElement(uint32_t aNamespace, nsAString& aTitle)
nsIContent* title = GetTitleContent(aNamespace);
if (!title)
return;
nsContentUtils::GetNodeTextContent(title, false, aTitle);
if(!nsContentUtils::GetNodeTextContent(title, false, aTitle))
NS_RUNTIMEABORT("OOM");
}
NS_IMETHODIMP

View File

@ -381,7 +381,9 @@ nsStyleLinkElement::DoUpdateStyleSheet(nsIDocument* aOldDocument,
nsresult rv = NS_OK;
if (isInline) {
nsAutoString text;
nsContentUtils::GetNodeTextContent(thisContent, false, text);
if (!nsContentUtils::GetNodeTextContent(thisContent, false, text)) {
return NS_ERROR_OUT_OF_MEMORY;
}
MOZ_ASSERT(thisContent->Tag() != nsGkAtoms::link,
"<link> is not 'inline', and needs different CSP checks");

View File

@ -1398,7 +1398,9 @@ nsTreeSanitizer::SanitizeChildren(nsINode* aRoot)
NS_ASSERTION(ns == kNameSpaceID_XHTML || ns == kNameSpaceID_SVG,
"Should have only HTML or SVG here!");
nsAutoString styleText;
nsContentUtils::GetNodeTextContent(node, false, styleText);
if (!nsContentUtils::GetNodeTextContent(node, false, styleText)) {
NS_RUNTIMEABORT("OOM");
}
nsAutoString sanitizedStyle;
nsCOMPtr<nsIURI> baseURI = node->GetBaseURI();
if (SanitizeStyleSheet(styleText,

View File

@ -322,7 +322,9 @@ IMPL_URI_PART(Hash)
NS_IMETHODIMP
HTMLAnchorElement::GetText(nsAString& aText)
{
nsContentUtils::GetNodeTextContent(this, true, aText);
if(!nsContentUtils::GetNodeTextContent(this, true, aText)) {
return NS_ERROR_OUT_OF_MEMORY;
}
return NS_OK;
}

View File

@ -371,7 +371,9 @@ void
HTMLMenuItemElement::GetText(nsAString& aText)
{
nsAutoString text;
nsContentUtils::GetNodeTextContent(this, false, text);
if (!nsContentUtils::GetNodeTextContent(this, false, text)) {
NS_RUNTIMEABORT("OOM");
}
text.CompressWhitespace(true, true);
aText = text;

View File

@ -144,7 +144,9 @@ HTMLOutputElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
void
HTMLOutputElement::GetValue(nsAString& aValue)
{
nsContentUtils::GetNodeTextContent(this, true, aValue);
if (!nsContentUtils::GetNodeTextContent(this, true, aValue)) {
NS_RUNTIMEABORT("OOM");
}
}
void
@ -175,7 +177,9 @@ HTMLOutputElement::HtmlFor()
void HTMLOutputElement::DescendantsChanged()
{
if (mValueModeFlag == eModeDefault) {
nsContentUtils::GetNodeTextContent(this, true, mDefaultValue);
if (!nsContentUtils::GetNodeTextContent(this, true, mDefaultValue)) {
NS_RUNTIMEABORT("OOM");
}
}
}

View File

@ -110,7 +110,9 @@ HTMLScriptElement::Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const
NS_IMETHODIMP
HTMLScriptElement::GetText(nsAString& aValue)
{
nsContentUtils::GetNodeTextContent(this, false, aValue);
if (!nsContentUtils::GetNodeTextContent(this, false, aValue)) {
return NS_ERROR_OUT_OF_MEMORY;
}
return NS_OK;
}

View File

@ -358,7 +358,9 @@ HTMLTextAreaElement::SetValueChanged(bool aValueChanged)
NS_IMETHODIMP
HTMLTextAreaElement::GetDefaultValue(nsAString& aDefaultValue)
{
nsContentUtils::GetNodeTextContent(this, false, aDefaultValue);
if (!nsContentUtils::GetNodeTextContent(this, false, aDefaultValue)) {
return NS_ERROR_OUT_OF_MEMORY;
}
return NS_OK;
}

View File

@ -42,7 +42,9 @@ HTMLTitleElement::WrapNode(JSContext* cx, JS::Handle<JSObject*> scope)
NS_IMETHODIMP
HTMLTitleElement::GetText(nsAString& aTitle)
{
nsContentUtils::GetNodeTextContent(this, false, aTitle);
if (!nsContentUtils::GetNodeTextContent(this, false, aTitle)) {
return NS_ERROR_OUT_OF_MEMORY;
}
return NS_OK;
}

View File

@ -116,7 +116,9 @@ SVGScriptElement::GetScriptType(nsAString& type)
void
SVGScriptElement::GetScriptText(nsAString& text)
{
nsContentUtils::GetNodeTextContent(this, false, text);
if (!nsContentUtils::GetNodeTextContent(this, false, text)) {
NS_RUNTIMEABORT("OOM");
}
}
void

View File

@ -288,7 +288,9 @@ nsXULTemplateQueryProcessorStorage::CompileQuery(nsIXULTemplateBuilder* aBuilder
nsAutoString sqlQuery;
// Let's get all text nodes (which should be the query)
nsContentUtils::GetNodeTextContent(queryContent, false, sqlQuery);
if (!nsContentUtils::GetNodeTextContent(queryContent, false, sqlQuery)) {
return NS_ERROR_OUT_OF_MEMORY;
}
nsresult rv = mStorageConnection->CreateStatement(NS_ConvertUTF16toUTF8(sqlQuery),
getter_AddRefs(statement));
@ -304,7 +306,9 @@ nsXULTemplateQueryProcessorStorage::CompileQuery(nsIXULTemplateBuilder* aBuilder
if (child->NodeInfo()->Equals(nsGkAtoms::param, kNameSpaceID_XUL)) {
nsAutoString value;
nsContentUtils::GetNodeTextContent(child, false, value);
if (!nsContentUtils::GetNodeTextContent(child, false, value)) {
return NS_ERROR_OUT_OF_MEMORY;
}
uint32_t index = parameterCount;
nsAutoString name, indexValue;

View File

@ -355,7 +355,9 @@ nsXBLPrototypeBinding::AttributeChanged(nsIAtom* aAttribute,
// Check to see if the src attribute is xbl:text. If so, then we need to obtain the
// children of the real element and get the text nodes' values.
if (aAttribute == nsGkAtoms::text && aNameSpaceID == kNameSpaceID_XBL) {
nsContentUtils::GetNodeTextContent(aChangedElement, false, value);
if (!nsContentUtils::GetNodeTextContent(aChangedElement, false, value)) {
NS_RUNTIMEABORT("OOM");
}
value.StripChar(char16_t('\n'));
value.StripChar(char16_t('\r'));
nsAutoString stripVal(value);
@ -506,8 +508,10 @@ SetAttrs(nsISupports* aKey, nsXBLAttributeEntry* aEntry, void* aClosure)
bool attrPresent = true;
if (src == nsGkAtoms::text && srcNs == kNameSpaceID_XBL) {
nsContentUtils::GetNodeTextContent(changeData->mBoundElement, false,
value);
if (!nsContentUtils::GetNodeTextContent(changeData->mBoundElement, false,
value)) {
NS_RUNTIMEABORT("OOM");
}
value.StripChar(char16_t('\n'));
value.StripChar(char16_t('\r'));
nsAutoString stripVal(value);

View File

@ -75,7 +75,10 @@ nsMathMLTokenFrame::MarkTextFramesAsTokenMathML()
}
if (mContent->Tag() == nsGkAtoms::mi_ && childCount == 1) {
nsAutoString data;
nsContentUtils::GetNodeTextContent(mContent, false, data);
if (!nsContentUtils::GetNodeTextContent(mContent, false, data)) {
NS_RUNTIMEABORT("OOM");
}
data.CompressWhitespace();
int32_t length = data.Length();

View File

@ -115,7 +115,10 @@ nsMathMLmoFrame::ProcessTextData()
mFlags = 0;
nsAutoString data;
nsContentUtils::GetNodeTextContent(mContent, false, data);
if (!nsContentUtils::GetNodeTextContent(mContent, false, data)) {
NS_RUNTIMEABORT("OOM");
}
data.CompressWhitespace();
int32_t length = data.Length();
char16_t ch = (length == 0) ? char16_t('\0') : data[0];