mirror of
https://github.com/go-delve/delve.git
synced 2025-10-29 01:27:16 +08:00
proc: map access with string literal key should always succeed (#3036)
When doing a map lookup with a string literal we should load as much of the keys to at least match the length of the string literal, so that the lookup doesn't fail with the "string too long" error. Fixes #3034
This commit is contained in:
committed by
GitHub
parent
a501814a99
commit
db3e5ef2cd
@ -2038,10 +2038,18 @@ func (v *Variable) mapAccess(idx *Variable) (*Variable, error) {
|
||||
return nil, fmt.Errorf("can not access unreadable map: %v", v.Unreadable)
|
||||
}
|
||||
|
||||
lcfg := loadFullValue
|
||||
if idx.Kind == reflect.String && int64(len(constant.StringVal(idx.Value))) == idx.Len && idx.Len > int64(lcfg.MaxStringLen) {
|
||||
// If the index is a string load as much of the keys to at least match the length of the index.
|
||||
//TODO(aarzilli): when struct literals are implemented this needs to be
|
||||
//done recursively for literal struct fields.
|
||||
lcfg.MaxStringLen = int(idx.Len)
|
||||
}
|
||||
|
||||
first := true
|
||||
for it.next() {
|
||||
key := it.key()
|
||||
key.loadValue(loadFullValue)
|
||||
key.loadValue(lcfg)
|
||||
if key.Unreadable != nil {
|
||||
return nil, fmt.Errorf("can not access unreadable map: %v", key.Unreadable)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user