Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 1683eb4fed1d7082bf4c1da27d39200bd739b9b9
https://github.com/WebKit/WebKit/commit/1683eb4fed1d7082bf4c1da27d39200bd739b9b9
Author: Chris Dumez <[email protected]>
Date: 2026-06-13 (Sat, 13 Jun 2026)
Changed paths:
A
LayoutTests/imported/w3c/web-platform-tests/css/css-values/random-unresolvable-argument.tentative-expected.txt
A
LayoutTests/imported/w3c/web-platform-tests/css/css-values/random-unresolvable-argument.tentative.html
M Source/WebCore/css/calc/CSSCalcTree+Evaluation.cpp
Log Message:
-----------
random() crashes when one of its arguments is invalid at computed-value time
https://bugs.webkit.org/show_bug.cgi?id=316972
Reviewed by Darin Adler.
The evaluator for random() in CSSCalcTree+Evaluation.cpp evaluated its `max`
argument but then re-checked `min` (already known to be engaged from the check
above) instead of `max`. As a result, a `max` argument that fails to evaluate at
computed-value time -- e.g. an anchor-size() used on a non-out-of-flow element,
which resolves to nothing -- was not caught, and the subsequent `*max` then
dereferenced a disengaged std::optional<double>. With hardened libc++ this traps
(SIGTRAP) and crashes the WebContent process; otherwise it reads uninitialized
memory and produces a garbage result.
Fix this by checking the result of evaluating `max`. When any argument fails to
resolve, random() correctly evaluates to nothing, making the declaration invalid
at computed-value time so the property falls back to its initial value.
Test:
imported/w3c/web-platform-tests/css/css-values/random-unresolvable-argument.tentative.html
*
LayoutTests/imported/w3c/web-platform-tests/css/css-values/random-unresolvable-argument.tentative-expected.txt:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-values/random-unresolvable-argument.tentative.html:
Added.
* Source/WebCore/css/calc/CSSCalcTree+Evaluation.cpp:
(WebCore::CSSCalc::evaluate):
Canonical link: https://commits.webkit.org/315177@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications