Commit 11cc5a26 authored by David Symonds's avatar David Symonds

reflect: panic if MakeSlice is given bad len/cap arguments.

Fixes #3330.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5847043
parent 8009542f
......@@ -1632,6 +1632,15 @@ func MakeSlice(typ Type, len, cap int) Value {
if typ.Kind() != Slice {
panic("reflect.MakeSlice of non-slice type")
}
if len < 0 {
panic("reflect.MakeSlice: negative len")
}
if cap < 0 {
panic("reflect.MakeSlice: negative cap")
}
if len > cap {
panic("reflect.MakeSlice: len > cap")
}
// Declare slice so that gc can see the base pointer in it.
var x []byte
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment