Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 65bc0fda9edd68bc4a2de32a3fc6d9a668c165d5
      
https://github.com/WebKit/WebKit/commit/65bc0fda9edd68bc4a2de32a3fc6d9a668c165d5
  Author: Chris Dumez <[email protected]>
  Date:   2026-03-26 (Thu, 26 Mar 2026)

  Changed paths:
    M Source/WebCore/platform/SharedBuffer.cpp

  Log Message:
  -----------
  utf8Buffer() in SharedBuffer.h allocates too much memory for 8-bit strings
https://bugs.webkit.org/show_bug.cgi?id=310770

Reviewed by Anne van Kesteren.

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.

* Source/WebCore/platform/SharedBuffer.cpp:
(WebCore::utf8Buffer):

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



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to