Closed Bug 397022 Opened 18 years ago Closed 18 years ago

nsCSSValue::Array leak involving overriding declarations of CSS 'content' property

Categories

(Core :: CSS Parsing and Computation, defect)

x86
macOS
defect
Not set
minor

Tracking

()

RESOLVED FIXED

People

(Reporter: jruderman, Assigned: dbaron)

References

Details

(Keywords: memory-leak, testcase)

Attachments

(2 files)

Attached file testcase
This testcase causes two nsCSSValue::Array objects to leak. (Tested with Mac trunk debug, XPCOM_MEM_LEAK_LOG=2.)
The problem is that nsRuleNode::ComputeContentData took the copy-construct codepath to allocate the nsStyleContent but then didn't release the old content->ContentAt().mContent.mCounters .
Except it should have, from reading the code, through ~nsStyleContentData. I must have missed something...
Ah, nsStyleContent::AllocateContents shouldn't have the (aCount != mContentCount) check because we need to run the destructors inside the DELETE_ARRAY_IF.
AllocateQuotes, AllocateCounterIncrements, and AllocateCounterResets should be OK since they allocate objects where assignment does the necessary destruction. (Then again, maybe that ought to be true for nsStyleContentData too.)
Attached patch patchSplinter Review
This is the simple fix. The alternative is making nsStyleContentData's members private and making it manage their lifetimes (except it would adopt the string on setting), but that seems like extra cycles and extra code for no present gain.
Assignee: nobody → dbaron
Status: NEW → ASSIGNED
Attachment #281905 - Flags: superreview?(bzbarsky)
Attachment #281905 - Flags: review?(bzbarsky)
Summary: nsCSSValue::Array leak involving CSS counter → nsCSSValue::Array leak involving overriding declarations of CSS 'content' property
Comment on attachment 281905 [details] [diff] [review] patch Makes sense. r+sr=bzbarsky
Attachment #281905 - Flags: superreview?(bzbarsky)
Attachment #281905 - Flags: superreview+
Attachment #281905 - Flags: review?(bzbarsky)
Attachment #281905 - Flags: review+
Fix checked in to trunk.
Status: ASSIGNED → RESOLVED
Closed: 18 years ago
Resolution: --- → FIXED
Crashtest checked in.
Flags: in-testsuite+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: