Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 429ffbc56515710b3d8d7c638a10179985def466
https://github.com/WebKit/WebKit/commit/429ffbc56515710b3d8d7c638a10179985def466
Author: Jeffrey Xu <[email protected]>
Date: 2026-06-29 (Mon, 29 Jun 2026)
Changed paths:
M Source/JavaScriptCore/API/glib/JSCContext.cpp
M Source/WTF/wtf/CheckedArithmetic.h
M Source/WTF/wtf/text/MakeString.h
Log Message:
-----------
Require two or more arguments for checked arithmetic operations.
rdar://129831277
Reviewed by Chris Dumez.
The one-argument versions of checkedSum and checkedProduct are prone to misuse
by performing the operation before passing the unchecked result to the
function, e.g. checkedSum(a + b). Using a fold expression removes the need to
include a base case, so we can require multiple arguments.
* Source/JavaScriptCore/API/glib/JSCContext.cpp: Fix unchecked addition.
* Source/WTF/wtf/CheckedArithmetic.h:
(WTF::checkedSum): Replace recursive variadic function with fold and add
requires expression.
(WTF::checkedProduct): Replace recursive variadic function with fold and add
requires expression.
* Source/WTF/wtf/text/MakeString.h:
(WTF::tryMakeStringFromAdapters): Add check to only call checkedSum if there's
two or more arguments.
(WTF::tryMakeAtomStringFromAdapters): Add check to only call checkedSum if
there's two or more arguments.
Canonical link: https://commits.webkit.org/316082@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications