File tree 2 files changed +22
-2
lines changed 2 files changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -1517,7 +1517,7 @@ func (v Value) MapIndex(key Value) Value {
1517
1517
// of unexported fields.
1518
1518
1519
1519
var e unsafe.Pointer
1520
- if key .kind () == String && tt .key .Kind () == String {
1520
+ if key .kind () == String && tt .key .Kind () == String && tt . elem . size <= maxValSize {
1521
1521
k := * (* string )(key .ptr )
1522
1522
e = mapaccess_faststr (v .typ , v .pointer (), k )
1523
1523
} else {
@@ -2128,7 +2128,7 @@ func (v Value) SetMapIndex(key, elem Value) {
2128
2128
key .mustBeExported ()
2129
2129
tt := (* mapType )(unsafe .Pointer (v .typ ))
2130
2130
2131
- if key .kind () == String && tt .key .Kind () == String {
2131
+ if key .kind () == String && tt .key .Kind () == String && tt . elem . size <= maxValSize {
2132
2132
k := * (* string )(key .ptr )
2133
2133
if elem .typ == nil {
2134
2134
mapdelete_faststr (v .typ , v .pointer (), k )
Original file line number Diff line number Diff line change
1
+ // run
2
+
3
+ // Copyright 2021 The Go Authors. All rights reserved.
4
+ // Use of this source code is governed by a BSD-style
5
+ // license that can be found in the LICENSE file.
6
+
7
+ package main
8
+
9
+ import "reflect"
10
+
11
+ type T [129 ]byte
12
+
13
+ func main () {
14
+ m := map [string ]T {}
15
+ v := reflect .ValueOf (m )
16
+ v .SetMapIndex (reflect .ValueOf ("a" ), reflect .ValueOf (T {}))
17
+ g = m ["a" ]
18
+ }
19
+
20
+ var g T
You can’t perform that action at this time.
0 commit comments