tree-sitter.tree-sitter/crates
Daniel Jalkut e4ac513afd lexer: pass code-unit length to U16_NEXT in UTF-16 decoders
`ts_decode_utf16_le` and `ts_decode_utf16_be` passed a byte length to
`U16_NEXT_LE` and `U16_NEXT_BE`, but those macros count `uint16_t` code
units. If a lead surrogate was the last code unit in a chunk, the decoder
could peek past the chunk and combine it with adjacent memory.

This commit passes the code-unit length to the UTF-16 macros, and fails
with `TS_DECODE_ERROR` when a chunk is too short to contain even one full
code unit. This lets the lexer retry with a fresh chunk or advance through
the invalid byte as it already does.

Co-authored-by: Will Lillis <will.lillis24@gmail.com>
Co-authored-by: Amaan Qureshi <git@amaanq.com>
(cherry picked from commit 0f6780b9a3)
2026-04-26 03:40:09 -04:00
..
cli lexer: pass code-unit length to U16_NEXT in UTF-16 decoders 2026-04-26 03:40:09 -04:00
config refactor(config)!: transition from anyhow to thiserror 2025-11-14 11:28:00 +01:00
generate fix(generate): pass default optimization level in 2026-04-24 09:19:20 +02:00
highlight fix(rust): fix new clippy lints 2026-04-23 02:19:20 -04:00
language 0.26.5 2026-02-01 20:27:27 +01:00
loader fix(rust): fix new clippy lints 2026-04-23 02:19:20 -04:00
tags chore: copy license to all packages 2025-09-11 03:12:35 -04:00
xtask feat(xtask): allow alternate branch for fixture grammars 2026-01-24 22:19:28 +01:00