proc: check recursion level when loading pointers (#3431)

Fixes #3429
This commit is contained in:
Alessandro Arzilli
2023-07-07 19:32:05 +02:00
committed by GitHub
parent 71f1220717
commit c1482ca911
3 changed files with 19 additions and 1 deletions

View File

@ -1305,10 +1305,21 @@ func (v *Variable) loadValueInternal(recurseLevel int, cfg LoadConfig) {
// Don't increase the recursion level when dereferencing pointers
// unless this is a pointer to interface (which could cause an infinite loop)
nextLvl := recurseLevel
checkLvl := false
if v.Children[0].Kind == reflect.Interface {
nextLvl++
} else if ptyp, isptr := v.RealType.(*godwarf.PtrType); isptr {
_, elemTypIsPtr := resolveTypedef(ptyp.Type).(*godwarf.PtrType)
if elemTypIsPtr {
nextLvl++
checkLvl = true
}
}
if checkLvl && recurseLevel > cfg.MaxVariableRecurse {
v.Children[0].OnlyAddr = true
} else {
v.Children[0].loadValueInternal(nextLvl, cfg)
}
v.Children[0].loadValueInternal(nextLvl, cfg)
} else {
v.Children[0].OnlyAddr = true
}