go/store/datas: FindCommonAncestor: Fix potential for explosive growth if RefsByHeight queues if the same references are visited multiple times.

This commit is contained in:
Aaron Son
2020-06-10 12:20:25 -07:00
parent 17a30a3c3a
commit d2a2f8da1d

View File

@@ -108,7 +108,14 @@ func FindCommonAncestor(ctx context.Context, c1, c2 types.Ref, vr types.ValueRea
}
func parentsToQueue(ctx context.Context, refs types.RefSlice, q *types.RefByHeight, vr types.ValueReader) error {
seen := make(map[hash.Hash]bool)
for _, r := range refs {
if _, ok := seen[r.TargetHash()]; ok {
continue
} else {
seen[r.TargetHash()] = true
}
v, err := r.TargetValue(ctx, vr)
if err != nil {