[Static Analysis][Resource leak] In function CustomElementRegistry::Define

RESOLVED FIXED in Firefox 53

Status

()

defect
RESOLVED FIXED
3 years ago
4 months ago

People

(Reporter: andi, Assigned: andi)

Tracking

(Blocks 1 bug, {coverity})

Trunk
mozilla53
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(firefox53 fixed)

Details

(Whiteboard: CID 1397481)

Attachments

(1 attachment)

The Static Analysis tool Coverity detected that a resource leak can happen in the following context:

>>   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;
>>   }

I think we should allocate definition after the if statement.
Comment on attachment 8828303 [details]
Bug 1332233 - prevent resource leak in CustomElementRegistry::Define.

https://reviewboard.mozilla.org/r/105764/#review106654
Attachment #8828303 - Flags: review?(amarchesini) → review+
Pushed by bpostelnicu@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/335c864df46d
prevent resource leak in CustomElementRegistry::Define. r=baku
https://hg.mozilla.org/mozilla-central/rev/335c864df46d
Status: NEW → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla53
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.