mirror of
https://github.com/oven-sh/bun
synced 2026-02-11 03:18:53 +00:00
## Summary - Fixes a crash where invalid slice bounds caused a panic with message: "start index N is larger than end index M" - The issue occurred in `js_lexer.zig:767` when calculating string literal content slice bounds - Adds proper bounds checking to prevent slice bounds violations - Includes regression test to prevent future occurrences ## Root Cause The crash happened when `suffix_len` was larger than `lexer.end`, causing the calculation `lexer.end - suffix_len` to result in a value smaller than the `base` position. This created invalid slice bounds like `[114..113]`. ## Solution Added bounds checking to ensure: 1. `end_pos` is calculated safely: `if (lexer.end >= suffix_len) lexer.end - suffix_len else lexer.end` 2. `slice_end` is always >= `base`: `@max(base, end_pos)` ## Test Plan - [x] Added regression test in `test/regression/issue/jsx-template-string-crash.test.ts` - [x] Test verifies no crashes occur with JSX template string patterns - [x] Verified normal template string functionality still works - [x] All tests pass 🤖 Generated with [Claude Code](https://claude.ai/code) --------- Co-authored-by: Jarred Sumner <jarred@jarredsumner.com> Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
1.2 KiB
1.2 KiB