Skip to content

Gracefully handle StringBuffer overflow in RegExp replace operator#59595

Merged
webkit-commit-queue merged 1 commit intoWebKit:mainfrom
asworkjsc:rdar-171058069
Mar 2, 2026
Merged

Gracefully handle StringBuffer overflow in RegExp replace operator#59595
webkit-commit-queue merged 1 commit intoWebKit:mainfrom
asworkjsc:rdar-171058069

Conversation

@asworkjsc
Copy link
Contributor

@asworkjsc asworkjsc commented Feb 27, 2026

e3c1c12

Gracefully handle StringBuffer overflow in RegExp replace operator
https://bugs.webkit.org/show_bug.cgi?id=308836
rdar://171058069

Reviewed by Marcus Plutowski.

When the RegExp replace operator is called, if the output string
overflows the maximum legal length of a javascript string it is
supposed to throw an out-of-memory error, rather than triggering a
controlled crash.

Test: JSTests/stress/string-regexp-replace-oom.js

* JSTests/stress/string-regexp-replace-oom.js: Added.
(Object.__proto__.__proto__.Symbol.replace):
(catch):
* Source/JavaScriptCore/runtime/RegExpPrototype.cpp:
(JSC::getSubstitution):

Canonical link: https://commits.webkit.org/308478@main

b1f4c50

Misc iOS, visionOS, tvOS & watchOS macOS Linux Windows Apple Internal
✅ 🧪 style ✅ 🛠 ios ✅ 🛠 mac ✅ 🛠 wpe 🛠 win ✅ 🛠 ios-apple
✅ 🛠 ios-sim ✅ 🛠 mac-AS-debug ✅ 🧪 wpe-wk2 🧪 win-tests ✅ 🛠 mac-apple
✅ 🧪 webkitperl ✅ 🧪 ios-wk2 ✅ 🧪 api-mac ✅ 🧪 api-wpe ✅ 🛠 vision-apple
✅ 🧪 ios-wk2-wpt ✅ 🧪 api-mac-debug ✅ 🛠 gtk3-libwebrtc
✅ 🛠 🧪 jsc ✅ 🧪 api-ios 🧪 mac-wk1 ✅ 🛠 gtk
✅ 🛠 🧪 jsc-debug-arm64 ✅ 🛠 ios-safer-cpp ✅ 🧪 mac-wk2 ✅ 🧪 gtk-wk2
✅ 🛠 vision ✅ 🧪 mac-AS-debug-wk2 ✅ 🧪 api-gtk
✅ 🛠 🧪 merge 🛠 vision-sim ✅ 🧪 mac-wk2-stress 🛠 playstation
🧪 vision-wk2 ✅ 🧪 mac-intel-wk2 ✅ 🛠 jsc-armv7
✅ 🛠 tv ✅ 🛠 mac-safer-cpp ✅ 🧪 jsc-armv7-tests
✅ 🛠 tv-sim
✅ 🛠 watch
✅ 🛠 watch-sim

@asworkjsc asworkjsc requested a review from a team as a code owner February 27, 2026 19:42
@asworkjsc asworkjsc self-assigned this Feb 27, 2026
@asworkjsc asworkjsc added the New Bugs Unclassified bugs are placed in this component until the correct component can be determined. label Feb 27, 2026
@hyjorc1 hyjorc1 added merge-queue Applied to send a pull request to merge-queue and removed merge-queue Applied to send a pull request to merge-queue labels Mar 2, 2026
@ast-hugger ast-hugger added merge-queue Applied to send a pull request to merge-queue and removed merge-queue Applied to send a pull request to merge-queue labels Mar 2, 2026
@asworkjsc asworkjsc added JavaScriptCore For bugs in JavaScriptCore, the JS engine used by WebKit, other than kxmlcore issues. and removed New Bugs Unclassified bugs are placed in this component until the correct component can be determined. labels Mar 2, 2026
@ast-hugger ast-hugger added the merge-queue Applied to send a pull request to merge-queue label Mar 2, 2026
https://bugs.webkit.org/show_bug.cgi?id=308836
rdar://171058069

Reviewed by Marcus Plutowski.

When the RegExp replace operator is called, if the output string
overflows the maximum legal length of a javascript string it is
supposed to throw an out-of-memory error, rather than triggering a
controlled crash.

Test: JSTests/stress/string-regexp-replace-oom.js

* JSTests/stress/string-regexp-replace-oom.js: Added.
(Object.__proto__.__proto__.Symbol.replace):
(catch):
* Source/JavaScriptCore/runtime/RegExpPrototype.cpp:
(JSC::getSubstitution):

Canonical link: https://commits.webkit.org/308478@main
@webkit-commit-queue
Copy link
Collaborator

Committed 308478@main (e3c1c12): https://commits.webkit.org/308478@main

Reviewed commits have been landed. Closing PR #59595 and removing active labels.

@webkit-commit-queue webkit-commit-queue merged commit e3c1c12 into WebKit:main Mar 2, 2026
@webkit-commit-queue webkit-commit-queue removed the merge-queue Applied to send a pull request to merge-queue label Mar 2, 2026
@asworkjsc asworkjsc deleted the rdar-171058069 branch March 2, 2026 20:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

JavaScriptCore For bugs in JavaScriptCore, the JS engine used by WebKit, other than kxmlcore issues.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants