reflect; SetLen() requires an addressable value

This commit is contained in:
Damian Gryski
2023-03-21 11:11:19 -07:00
committed by Ayke
parent 4d43df75d5
commit 17f5fb1071
2 changed files with 3 additions and 1 deletions
+1 -1
View File
@@ -999,7 +999,7 @@ func (v Value) SetLen(n int) {
if v.typecode.Kind() != Slice {
panic(&ValueError{Method: "reflect.Value.SetLen", Kind: v.Kind()})
}
v.checkAddressable()
hdr := (*sliceHeader)(v.value)
if int(uintptr(n)) != n || uintptr(n) > hdr.cap {
panic("reflect.Value.SetLen: slice length out of range")