Bug 1332233 - prevent resource leak in CustomElementRegistry::Define. r=baku
authorAndi-Bogdan Postelnicu <bpostelnicu@mozilla.com>
Thu, 19 Jan 2017 14:31:33 +0200
changeset 375161 335c864df46df0b894d8d5f78aec957649d86e97
parent 375031 168ea3e9ff0bad286676173263613703187ab8f1
child 375162 b07a797b00e5ddfad1eb6083c8a8edb3cf5d2632
push id6996
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 20:48:21 +0000
treeherdermozilla-beta@d89512dab048 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbaku
bugs1332233
milestone53.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 1332233 - prevent resource leak in CustomElementRegistry::Define. r=baku MozReview-Commit-ID: AzXgls3lKCA
dom/base/CustomElementRegistry.cpp
--- a/dom/base/CustomElementRegistry.cpp
+++ b/dom/base/CustomElementRegistry.cpp
@@ -767,32 +767,33 @@ CustomElementRegistry::Define(const nsAS
    * 11. Let definition be a new custom element definition with name name,
    *     local name localName, constructor constructor, prototype prototype,
    *     observed attributes observedAttributes, and lifecycle callbacks
    *     lifecycleCallbacks.
    */
   // Associate the definition with the custom element.
   nsCOMPtr<nsIAtom> localNameAtom(NS_Atomize(localName));
   LifecycleCallbacks* callbacks = callbacksHolder.forget();
-  CustomElementDefinition* definition =
-    new CustomElementDefinition(nameAtom,
-                                localNameAtom,
-                                constructor,
-                                constructorPrototype,
-                                callbacks,
-                                0 /* TODO dependent on HTML imports. Bug 877072 */);
 
   /**
    * 12. Add definition to this CustomElementRegistry.
    */
   if (!mConstructors.put(constructorUnwrapped, nameAtom)) {
     aRv.Throw(NS_ERROR_FAILURE);
     return;
   }
 
+  CustomElementDefinition* definition =
+    new CustomElementDefinition(nameAtom,
+                                localNameAtom,
+                                constructor,
+                                constructorPrototype,
+                                callbacks,
+                                0 /* TODO dependent on HTML imports. Bug 877072 */);
+
   mCustomDefinitions.Put(nameAtom, definition);
 
   MOZ_ASSERT(mCustomDefinitions.Count() == mConstructors.count(),
              "Number of entries should be the same");
 
   /**
    * 13. 14. 15. Upgrade candidates
    */