Bug 1332233 - prevent resource leak in CustomElementRegistry::Define.

Tag UXP Issue #1344
This commit is contained in:
Gaming4JC 2020-01-05 12:15:22 -05:00 • committed by Roy Tam
commit 6f325a61af

View file

@ -817,14 +817,6 @@ CustomElementRegistry::Define(const nsAString& aName,
// Associate the definition with the custom element.
nsCOMPtr<nsIAtom> 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(),