Bug 1428860 - XULDocument::GetElementsByAttributeNS may leak memory r?peterv draft
authorJean-Luc Bonnafoux <jeanluc.bonnafoux@wanadoo.fr>
Mon, 22 Jan 2018 18:51:44 +0100
changeset 723196 2cc7174bfc55e5959e9c5e1f8a2605d29f26b02e
parent 716678 07e377e19c7d462a4dc2e674e0163a400b3a572d
child 746797 3df301465344584c837d30e9a5dda7419500fbb2
child 748381 bf335186c9175901c0cf2ee9afe75001c2e60143
child 750265 6b877f202ef4f1365edb33049a720bf4155e7069
push id96359
push userbmo:jeanluc.bonnafoux@wanadoo.fr
push dateMon, 22 Jan 2018 18:18:18 +0000
reviewerspeterv
bugs1428860
milestone59.0a1
Bug 1428860 - XULDocument::GetElementsByAttributeNS may leak memory r?peterv MozReview-Commit-ID: 5tRvcFq80DD
dom/xul/XULDocument.cpp
--- 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