Bug 1428860 - XULDocument::GetElementsByAttributeNS may leak memory r?peterv
MozReview-Commit-ID: 5tRvcFq80DD
--- a/dom/xul/XULDocument.cpp
+++ b/dom/xul/XULDocument.cpp
@@ -1111,21 +1111,21 @@ XULDocument::GetElementsByAttribute(cons
return NS_OK;
}
already_AddRefed<nsINodeList>
XULDocument::GetElementsByAttribute(const nsAString& aAttribute,
const nsAString& aValue)
{
RefPtr<nsAtom> attrAtom(NS_Atomize(aAttribute));
- void* attrValue = new nsString(aValue);
+ nsAutoPtr<nsString> attrValue = new nsString(aValue);
RefPtr<nsContentList> list = new nsContentList(this,
MatchAttribute,
nsContentUtils::DestroyMatchString,
- attrValue,
+ reinterpret_cast<void*>(attrValue.forget()),
true,
attrAtom,
kNameSpaceID_Unknown);
return list.forget();
}
NS_IMETHODIMP