tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit e22df3f03bc398bf6a5c0ff11840a3a9c28c12cb
parent 678a5e4bec55d7bd5729fe4af76dba52f390fcc2
Author: Jan Varga <Jan.Varga@gmail.com>
Date:   Tue, 21 Oct 2025 14:55:21 +0000

Bug 1995429 - Move forwarded callable outside retry loop in CallWithDelayedRetriesIfAccessDenied; r=dom-storage-reviewers,jari

std::forward should only be used once per parameter. In the retry loop, the
forwarded callable was potentially moved multiple times, leaving it in an
undefined state for subsequent iterations. Move the callable into a local
variable before entering the loop.

Differential Revision: https://phabricator.services.mozilla.com/D269303

Diffstat:
Mdom/quota/QuotaCommon.h | 4+++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/dom/quota/QuotaCommon.h b/dom/quota/QuotaCommon.h @@ -1652,10 +1652,12 @@ template <typename Func> auto CallWithDelayedRetriesIfAccessDenied(Func&& aFunc, uint32_t aMaxRetries, uint32_t aDelayMs) -> Result<typename std::invoke_result_t<Func>::ok_type, nsresult> { + std::decay_t<Func> func = std::forward<Func>(aFunc); + uint32_t retries = 0; while (true) { - auto result = std::forward<Func>(aFunc)(); + auto result = std::invoke(func); if (result.isOk()) { return result;