mirror of
https://github.com/oven-sh/bun
synced 2026-02-17 22:32:06 +00:00
## Summary Fixed a bug in the Windows bunx fast path code where UTF-8 byte length was incorrectly used instead of UTF-16 code unit length when calculating buffer offsets. ## Details In `run_command.zig:1565`, the code was using `target_name.len` (UTF-8 byte length) instead of `encoded.len` (UTF-16 code unit length) when calculating the total path length. This caused an index out of bounds panic when package names contained multi-byte UTF-8 characters. **Example scenario:** - Package name contains character "中" (U+4E2D) - UTF-8: 3 bytes (0xE4 0xB8 0xAD) → `target_name.len` counts as 3 - UTF-16: 1 code unit (0x4E2D) → `encoded.len` counts as 1 - Using the wrong length led to: `panic: index out of bounds: index 62, len 60` ## Changes - Changed line 1565 from `target_name.len` to `encoded.len` ## Test plan - [x] Build compiles successfully - [x] Code review confirms the fix addresses the root cause - [ ] Windows-specific testing (if available) Fixes the panic reported in Sentry/crash reports. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Bot <claude-bot@bun.sh> Co-authored-by: Claude <noreply@anthropic.com>