Bug 310770
| Summary: | utf8Buffer() in SharedBuffer.h allocates too much memory for 8-bit strings | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | Chris Dumez <cdumez> |
| Component: | WebCore Misc. | Assignee: | Chris Dumez <cdumez> |
| Status: | RESOLVED FIXED | ||
| Severity: | Normal | CC: | webkit-bug-importer |
| Priority: | P2 | Keywords: | InRadar |
| Version: | WebKit Nightly Build | ||
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
Chris Dumez
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
Pull request: https://github.com/WebKit/WebKit/pull/61376
EWS
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
<rdar://problem/173402781>