Files
sousa-gecko/dom/prototype
Daniel Holbert 10725540f6 Bug 2037754: Use 'MakeAndAddRef' instead of 'new' when allocating runnable for nsContentUtils::AddScriptRunner. r=dom-core,smaug
MakeAndAddRef ensures that the freshly-allocated object immediately gets a
refcount of 1 (before it's even passed to AddScriptRunner).  This avoids
several potential footguns that otherwise exist with a zero-refcount
freshly-allocated object.

It also makes the ownership-transfer semantics more clear
(via the already_AddRefed type that it produces) - AddScriptRunner is taking
ownership of the object, rather than using it temporarily while the caller
maintains ownership.

Differential Revision: https://phabricator.services.mozilla.com/D299039
2026-05-07 06:35:57 +00:00
..