WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
310770
utf8Buffer() in SharedBuffer.h allocates too much memory for 8-bit strings
https://bugs.webkit.org/show_bug.cgi?id=310770
Summary
utf8Buffer() in SharedBuffer.h allocates too much memory for 8-bit strings
Chris Dumez
Reported
2026-03-25 22:33:27 PDT
Latin1 characters (0x80-0xFF) encode as at most 2 UTF-8 bytes; ASCII (0x00-0x7F) as 1 byte. So length * 2 is sufficient for 8-bit strings. The 3x multiplier is only needed for 16-bit strings (a single BMP codepoint can be 3 UTF-8 bytes). Additionally, Vector<uint8_t> buffer(length * 3) zero-initializes the entire allocation, so the waste is both allocation and initialization.
Attachments
Add attachment
proposed patch, testcase, etc.
Chris Dumez
Comment 1
2026-03-25 22:35:17 PDT
Pull request:
https://github.com/WebKit/WebKit/pull/61376
EWS
Comment 2
2026-03-26 06:22:29 PDT
Committed
309984@main
(65bc0fda9edd): <
https://commits.webkit.org/309984@main
> Reviewed commits have been landed. Closing PR #61376 and removing active labels.
Radar WebKit Bug Importer
Comment 3
2026-03-26 06:23:13 PDT
<
rdar://problem/173402781
>
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug