Migrate new/delete to UniquePtr in nsTableFrame.cpp
Categories
(Core :: Layout: Tables, task)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox100 | --- | fixed |
People
(Reporter: dholbert, Assigned: dshin)
Details
Attachments
(3 external files)
(Filing this as a possible relatively-straightforward good-first-bug for new team members.)
nsTableFrame.cpp has several manual new/delete invocations. We should migrate those to use mozilla::UniquePtr to avoid the potential for leaks and double-free bugs.
In particular, I'm noticing the BCPaintBorderIterator class's member-var mBlockDirInfo, which we lazily-initialize and then delete in the destructor if it's non-null:
https://searchfox.org/mozilla-central/rev/73a8000b0c0eb527faef01ea17c6d2398622a386/layout/tables/nsTableFrame.cpp#5982-5984
This would make for a good first conversion-to-UniquePtr. And then after that, I'd suggest looking through that .cpp file for other explicit delete invocations for other possible conversion opportunities.
| Reporter | ||
Updated•4 years ago
|
| Reporter | ||
Comment 1•4 years ago
|
||
For reference, here's the UniquePtr documentation which is pretty good - I'd skim this "Usage" section before getting started here:
https://searchfox.org/mozilla-central/rev/1c54648c082efdeb08cf6a5e3a8187e83f7549b9/mfbt/UniquePtr.h#94
(And if it's useful, here's a search for other UniquePtr usages in layout, for more sample-usage: https://searchfox.org/mozilla-central/search?q=UniquePtr&path=layout )
| Reporter | ||
Comment 2•4 years ago
•
|
||
Also, I forgot to mention in comment 0: as part of this conversion, we should switch from new to the safer MakeUnique when allocating for the variables in question here, e.g. on this line:
https://searchfox.org/mozilla-central/rev/73a8000b0c0eb527faef01ea17c6d2398622a386/layout/tables/nsTableFrame.cpp#6253
See documentation on MakeUnique (and why it's preferred) here:
https://searchfox.org/mozilla-central/rev/1c54648c082efdeb08cf6a5e3a8187e83f7549b9/mfbt/UniquePtr.h#554
| Reporter | ||
Comment 3•4 years ago
|
||
This patch may also be useful for reference, as an earlier place where I migrated some memory to be managed by UniquePtr:
https://phabricator.services.mozilla.com/D84463
| Assignee | ||
Comment 4•4 years ago
|
||
| Assignee | ||
Updated•4 years ago
|
Comment 6•4 years ago
|
||
| bugherder | ||
| Assignee | ||
Comment 7•4 years ago
|
||
| Assignee | ||
Comment 8•4 years ago
|
||
Depends on D142080
| Assignee | ||
Updated•4 years ago
|
Comment 10•4 years ago
|
||
| bugherder | ||
https://hg.mozilla.org/mozilla-central/rev/3c5073b93115
https://hg.mozilla.org/mozilla-central/rev/dd81d58d9d5f
Description
•