Skip to content

fix: add bounds checking to charAt and charCodeAt#232

Merged
cs01 merged 1 commit intomainfrom
fix/string-bounds-check
Mar 11, 2026
Merged

fix: add bounds checking to charAt and charCodeAt#232
cs01 merged 1 commit intomainfrom
fix/string-bounds-check

Conversation

@cs01
Copy link
Copy Markdown
Owner

@cs01 cs01 commented Mar 11, 2026

Summary

  • charAt and charCodeAt had no bounds checking — negative or out-of-bounds indices would read unowned memory (potential crash/security issue)
  • now checks index >= 0 && index < strlen(str) before accessing
  • out-of-bounds charAt returns empty string, charCodeAt returns 0 (matching JS semantics)

Test plan

  • new test: strings/string-charat-bounds.ts — validates in-bounds and OOB behavior
  • verify:quick passes (tests + stage 1 self-hosting)

🤖 Generated with Claude Code

@cs01 cs01 merged commit af6b49c into main Mar 11, 2026
12 checks passed
@cs01 cs01 deleted the fix/string-bounds-check branch March 12, 2026 05:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant