Skip to content

fix: clamp splice start index to array length (#297)#297

Merged
cs01 merged 1 commit intomainfrom
fix-splice-past-end
Mar 12, 2026
Merged

fix: clamp splice start index to array length (#297)#297
cs01 merged 1 commit intomainfrom
fix-splice-past-end

Conversation

@cs01
Copy link
Copy Markdown
Owner

@cs01 cs01 commented Mar 12, 2026

Summary

  • array.splice(100, 1) on a 3-element array no longer corrupts memory — start index is now clamped to <= length (was only clamped to >= 0)
  • Without clamping, remaining = length - start goes negative, causing memcpy/memmove with huge unsigned sizes
  • Fix applies to both numeric and string arrays
  • Adds test fixture for splice with out-of-bounds start index

Test plan

  • npm run verify:quick passes
  • New array-splice-past-end.ts test passes
  • Existing splice tests still pass

🤖 Generated with Claude Code

…etecount

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@cs01 cs01 merged commit 93f51ff into main Mar 12, 2026
12 checks passed
@cs01 cs01 deleted the fix-splice-past-end branch March 12, 2026 19:15
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