Bug 1428860 - XULDocument::GetElementsByAttributeNS may leak memory r=peterv
authorJean-Luc Bonnafoux <jeanluc.bonnafoux@wanadoo.fr>
Sun, 25 Feb 2018 12:07:52 +0100
changeset 405855 7431e41b5d95133eb540005e021457c9acfb885c
parent 405854 44363ede4383eb408440343b389c4f989e508197
child 405856 d4b47e577288cfadacd94a9706af31db83feef2d
push id33536
push usertoros@mozilla.com
push dateThu, 01 Mar 2018 17:11:23 +0000
treeherdermozilla-central@bf8a7dceffc4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspeterv
bugs1428860
milestone60.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: 5NjViIoivG1
dom/xul/XULDocument.cpp
--- a/dom/xul/XULDocument.cpp
+++ b/dom/xul/XULDocument.cpp
@@ -1068,52 +1068,52 @@ XULDocument::ResolveForwardReferences()
 // nsIDOMDocument interface
 //
 
 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,
+                                            attrValue.forget(),
                                             true,
                                             attrAtom,
                                             kNameSpaceID_Unknown);
 
     return list.forget();
 }
 
 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();
 }
 
 void
 XULDocument::Persist(const nsAString& aID,