util/deephash: prevent infinite loop on map cycle
Fixes #2340 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:

committed by
Brad Fitzpatrick

parent
aceaa70b16
commit
3962744450
@ -226,3 +226,15 @@ func TestSHA256EqualHex(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// verify this doesn't loop forever, as it used to (Issue 2340)
|
||||
func TestMapCyclicFallback(t *testing.T) {
|
||||
type T struct {
|
||||
M map[string]interface{}
|
||||
}
|
||||
v := &T{
|
||||
M: map[string]interface{}{},
|
||||
}
|
||||
v.M["m"] = v.M
|
||||
Hash(v)
|
||||
}
|
||||
|
Reference in New Issue
Block a user