Closed Bug 1029180 Opened 7 years ago Closed 7 years ago

Remove dangerous public destructor of nsStyleContext

Categories

(Core :: CSS Parsing and Computation, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla33

People

(Reporter: dholbert, Assigned: dholbert)

Details

Attachments

(1 file)

Noticed that nsStyleContext (which provides its own AddRef() / Release() methods) has a public destructor.

We should make its destructor private, to prevent ourselves from accidentally instantiating it outside of a nsRefPtr, per
https://groups.google.com/d/msg/mozilla.dev.platform/jMDAQtBzdCA/_c8tpG6TnFoJ
and related bugs. (bug 984786, bug 1027251)
Attached patch fix v1Splinter Review
Attachment #8444751 - Flags: review?(cam)
Attachment #8444751 - Flags: review?(cam) → review+
To make this less likely to regress accidentally, you could use MOZ_ASSERT_TYPE_OK_FOR_REFCOUNTING. It is currently only used internally in nsISupportsImpl.h but it's OK to start relying on it. We have to expose it anyway, as far as my understanding of the C preprocessor goes.
https://hg.mozilla.org/mozilla-central/rev/60853c061684
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla33
You need to log in before you can comment on or make changes to this bug.