Skip to content

Return errors instead of panicking on make with negative sizes - #372

Merged
mattn merged 1 commit into
masterfrom
fix-make-negative-panic
Jul 9, 2026
Merged

Return errors instead of panicking on make with negative sizes#372
mattn merged 1 commit into
masterfrom
fix-make-negative-panic

Conversation

@mattn

@mattn mattn commented Jul 9, 2026

Copy link
Copy Markdown
Owner

make([]int64, -1) and make(chan int64, -1) crashed the host program with uncaught reflect panics (reflect.MakeSlice: negative len / reflect.MakeChan: negative buffer size). Negative len and cap now return VM errors like the existing len > cap check.

@mattn
mattn merged commit 6dd86ad into master Jul 9, 2026
12 checks passed
@mattn
mattn deleted the fix-make-negative-panic branch July 10, 2026 00:43
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