Skip to content

Conversation

@cole-miller
Copy link
Member

Closes #40359

We were segfaulting when opening a UTF-8 file starting with a byte order mark due to a mismatch in our UTF-16 indexing calculations caused by Core Foundations replace_str stripping the BOM internally. This PR fixes the crash by replacing one of our manual calculations by calling the Core Foundations API to get the length of a string.

Release Notes:

  • Fixed a crash on macOS when opening a file that starts with a UTF-8 byte order mark (BOM).
Co-authored-by: HactarCE <6060305+HactarCE@users.noreply.github.com>
@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Oct 16, 2025
@cole-miller cole-miller enabled auto-merge (squash) October 16, 2025 19:45
@cole-miller cole-miller merged commit b26491f into main Oct 16, 2025
23 checks passed
@cole-miller cole-miller deleted the fix-mac-bom-crash branch October 16, 2025 20:04
xipeng-jin pushed a commit to xipeng-jin/zed that referenced this pull request Oct 17, 2025
Closes zed-industries#40359

We were segfaulting when opening a UTF-8 file starting with a byte order
mark due to a mismatch in our UTF-16 indexing calculations caused by
Core Foundations `replace_str` stripping the BOM internally. This PR
fixes the crash by replacing one of our manual calculations by calling
the Core Foundations API to get the length of a string.

Release Notes:

- Fixed a crash on macOS when opening a file that starts with a UTF-8
byte order mark (BOM).

Co-authored-by: HactarCE <6060305+HactarCE@users.noreply.github.com>
P1n3appl3 pushed a commit to P1n3appl3/zed that referenced this pull request Oct 18, 2025
Closes zed-industries#40359

We were segfaulting when opening a UTF-8 file starting with a byte order
mark due to a mismatch in our UTF-16 indexing calculations caused by
Core Foundations `replace_str` stripping the BOM internally. This PR
fixes the crash by replacing one of our manual calculations by calling
the Core Foundations API to get the length of a string.

Release Notes:

- Fixed a crash on macOS when opening a file that starts with a UTF-8
byte order mark (BOM).

Co-authored-by: HactarCE <6060305+HactarCE@users.noreply.github.com>
mikayla-maki pushed a commit that referenced this pull request Oct 21, 2025
Closes #40359

We were segfaulting when opening a UTF-8 file starting with a byte order
mark due to a mismatch in our UTF-16 indexing calculations caused by
Core Foundations `replace_str` stripping the BOM internally. This PR
fixes the crash by replacing one of our manual calculations by calling
the Core Foundations API to get the length of a string.

Release Notes:

- Fixed a crash on macOS when opening a file that starts with a UTF-8
byte order mark (BOM).

Co-authored-by: HactarCE <6060305+HactarCE@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement

2 participants