Bug 1428860 - XULDocument::GetElementsByAttributeNS may leak memory r=peterv
☠☠ backed out by d5c253aa5fb3 ☠ ☠
authorJean-Luc Bonnafoux <jeanluc.bonnafoux@wanadoo.fr>
Sat, 13 Jan 2018 12:57:26 +0100
changeset 454440 721e8ff721d8b0c81af2c91e3fb660a8cb0be058
parent 454439 2fa6fe0e8a8097f894753d45f5b1a1853a8d1d46
child 454441 d5c253aa5fb326756cc03ba2ae3d75226b0a1648
push id1648
push usermtabara@mozilla.com
push dateThu, 01 Mar 2018 12:45:47 +0000
treeherdermozilla-release@cbb9688c2eeb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspeterv
bugs1428860
milestone59.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1428860 - XULDocument::GetElementsByAttributeNS may leak memory r=peterv MozReview-Commit-ID: EZS6vbteDUo
dom/xul/XULDocument.cpp
--- a/dom/xul/XULDocument.cpp
+++ b/dom/xul/XULDocument.cpp
@@ -1141,33 +1141,33 @@ XULDocument::GetElementsByAttributeNS(co
 
 already_AddRefed<nsINodeList>
 XULDocument::GetElementsByAttributeNS(const nsAString& aNamespaceURI,
                                       const nsAString& aAttribute,
                                       const nsAString& aValue,
                                       ErrorResult& aRv)
 {
     RefPtr<nsAtom> attrAtom(NS_Atomize(aAttribute));
-    void* attrValue = new nsString(aValue);
+    nsAutoPtr<nsString> attrValue = new nsString(aValue);
 
     int32_t nameSpaceId = kNameSpaceID_Wildcard;
     if (!aNamespaceURI.EqualsLiteral("*")) {
       nsresult rv =
         nsContentUtils::NameSpaceManager()->RegisterNameSpace(aNamespaceURI,
                                                               nameSpaceId);
       if (NS_FAILED(rv)) {
           aRv.Throw(rv);
           return nullptr;
       }
     }
 
     RefPtr<nsContentList> list = new nsContentList(this,
                                             MatchAttribute,
                                             nsContentUtils::DestroyMatchString,
-                                            attrValue,
+                                            attrValue.forget(),
                                             true,
                                             attrAtom,
                                             nameSpaceId);
     return list.forget();
 }
 
 NS_IMETHODIMP
 XULDocument::Persist(const nsAString& aID,