Skip to content

fix: prevent i32 overflow in array/string copy size calculations#268

Merged
cs01 merged 1 commit intomainfrom
fix/array-copy-overflow
Mar 12, 2026
Merged

fix: prevent i32 overflow in array/string copy size calculations#268
cs01 merged 1 commit intomainfrom
fix/array-copy-overflow

Conversation

@cs01
Copy link
Copy Markdown
Owner

@cs01 cs01 commented Mar 12, 2026

Summary

  • Fixes integer overflow when computing memcpy sizes for large arrays: mul i32 len, 8 overflows for arrays with >268M elements, causing wrong-sized copies and potential memory corruption
  • Pattern: zext i32 to i64 first, then multiply in 64-bit — matches the correct pattern already used in numeric array push
  • Fixed in 3 files: array mutators (string/object array push expand), string split allocation, promise.all/race result allocation

Test plan

  • npm run verify:quick passes (tests + Stage 1 self-hosting)
  • No behavioral change for normal-sized arrays — only prevents overflow for very large ones

🤖 Generated with Claude Code

@cs01 cs01 merged commit 7bd6f95 into main Mar 12, 2026
12 checks passed
@cs01 cs01 deleted the fix/array-copy-overflow branch March 12, 2026 05:34
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