mirror of https://github.com/golang/go.git
reflect: panic if MakeSlice is given bad len/cap arguments.
Fixes #3330. R=golang-dev, r CC=golang-dev https://golang.org/cl/5847043
This commit is contained in:
parent
8009542f55
commit
11cc5a26d5
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue