Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit631401a

Browse files
cartermpKevinRansom
authored andcommitted
Do not get the absolute value of Map's hash code (dotnet#6072)
Fixesdotnet#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.
1 parent23c626d commit631401a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

‎src/fsharp/FSharp.Core/map.fs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ namespace Microsoft.FSharp.Collections
558558
for(KeyValue(x,y))in thisdo
559559
res<- combineHash res(hash x)
560560
res<- combineHash res(Unchecked.hash y)
561-
absres
561+
res
562562

563563
overridethis.Equals(that)=
564564
match thatwith
@@ -744,4 +744,4 @@ namespace Microsoft.FSharp.Collections
744744
letempty<'Key,'Valuewhen'Key:comparison>= Map<'Key,'Value>.Empty
745745

746746
[<CompiledName("Count")>]
747-
letcount(table:Map<_,_>)= table.Count
747+
letcount(table:Map<_,_>)= table.Count

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp