Closed Bug 1287166 Opened 3 years ago Closed 3 years ago

Use a little less NS_ADDREF in DOM code

Categories

(Core :: DOM: Core & HTML, defect)

defect
Not set

Tracking

()

RESOLVED FIXED
mozilla50
Tracking Status
firefox50 --- fixed

People

(Reporter: mccr8, Assigned: mccr8)

Details

Attachments

(1 file)

No description provided.
Comment on attachment 8772561 [details] [diff] [review]
Use NS_ADDREF less in dom/.

Review of attachment 8772561 [details] [diff] [review]:
-----------------------------------------------------------------

r=me with comments addressed.

::: dom/base/nsGenericDOMDataNode.h
@@ +172,5 @@
>  
>    virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult) const override
>    {
> +    nsCOMPtr<nsINode> result = CloneDataNode(aNodeInfo, true);
> +    if (!result) {

The previous code had the side effect of clearing *aResult when CloneDataNode() returned nullptr.  It would be slightly safer to put the forget() before the short-circuit here.  If you are sure it doesn't matter, though, then this is fine.
Attachment #8772561 - Flags: review?(bkelly) → review+
That's a good point. I'll do that.
https://hg.mozilla.org/mozilla-central/rev/bf7983226fbe
Status: NEW → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla50
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.