Bug 1332233 - prevent resource leak in CustomElementRegistry::Define. r?baku
MozReview-Commit-ID: AzXgls3lKCA
--- 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
*/