提交 631401a1 编写于 作者: P Phillip Carter 提交者: Kevin Ransom (msft)

Do not get the absolute value of Map's hash code (#6072)

Fixes #6068, where you could cause a `System.OverFlowException` by using a key and value that leads to calling `abs` on `Int32.MinValue`. This is invalid on .NET. The fix is to not call `abs`, since there's really no reason to make a hash code always positive.
上级 23c626d7
......@@ -558,7 +558,7 @@ namespace Microsoft.FSharp.Collections
for (KeyValue(x,y)) in this do
res <- combineHash res (hash x)
res <- combineHash res (Unchecked.hash y)
abs res
res
override this.Equals(that) =
match that with
......@@ -744,4 +744,4 @@ namespace Microsoft.FSharp.Collections
let empty<'Key,'Value when 'Key : comparison> = Map<'Key,'Value>.Empty
[<CompiledName("Count")>]
let count (table:Map<_,_>) = table.Count
\ No newline at end of file
let count (table:Map<_,_>) = table.Count
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册