From 49f597e7fb83dc96bfcf66073fe5bfbf994d71ba Mon Sep 17 00:00:00 2001 From: Gaming4JC Date: Sun, 5 Jan 2020 12:15:22 -0500 Subject: Bug 1332233 - prevent resource leak in CustomElementRegistry::Define. Tag UXP Issue #1344 --- dom/base/CustomElementRegistry.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'dom') diff --git a/dom/base/CustomElementRegistry.cpp b/dom/base/CustomElementRegistry.cpp index 34ad9549d..897f7df12 100644 --- a/dom/base/CustomElementRegistry.cpp +++ b/dom/base/CustomElementRegistry.cpp @@ -817,14 +817,6 @@ CustomElementRegistry::Define(const nsAString& aName, // Associate the definition with the custom element. nsCOMPtr localNameAtom(NS_Atomize(localName)); LifecycleCallbacks* callbacks = callbacksHolder.forget(); - CustomElementDefinition* definition = - new CustomElementDefinition(nameAtom, - localNameAtom, - &aFunctionConstructor, - Move(observedAttributes), - constructorPrototype, - callbacks, - 0 /* TODO dependent on HTML imports. Bug 877072 */); /** * 12. Add definition to this CustomElementRegistry. @@ -834,6 +826,15 @@ CustomElementRegistry::Define(const nsAString& aName, return; } + CustomElementDefinition* definition = + new CustomElementDefinition(nameAtom, + localNameAtom, + &aFunctionConstructor, + Move(observedAttributes), + constructorPrototype, + callbacks, + 0 /* TODO dependent on HTML imports. Bug 877072 */); + mCustomDefinitions.Put(nameAtom, definition); MOZ_ASSERT(mCustomDefinitions.Count() == mConstructors.count(), -- cgit v1.2.3