Skip to content

Commit 4aeab3d

Browse files
authored
Merge pull request #648 from moiseev/version-overflow-ccc
[swift-3.0-branch] Eliminating integer overflow in Version
2 parents c784ad8 + 1a4aa3b commit 4aeab3d

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

Sources/PackageDescription/Version.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,12 @@ extension Version: Hashable {
4949
// inspired code inside the Swift stdlib.
5050
let mul: UInt64 = 0x9ddfea08eb382d69
5151
var result: UInt64 = 0
52-
result = (result &* mul) ^ UInt64(major.hashValue)
53-
result = (result &* mul) ^ UInt64(minor.hashValue)
54-
result = (result &* mul) ^ UInt64(patch.hashValue)
55-
result = prereleaseIdentifiers.reduce(result, { ($0 &* mul) ^ UInt64($1.hashValue) })
52+
result = (result &* mul) ^ UInt64(bitPattern: Int64(major.hashValue))
53+
result = (result &* mul) ^ UInt64(bitPattern: Int64(minor.hashValue))
54+
result = (result &* mul) ^ UInt64(bitPattern: Int64(patch.hashValue))
55+
result = prereleaseIdentifiers.reduce(result, { ($0 &* mul) ^ UInt64(bitPattern: Int64($1.hashValue)) })
5656
if let build = buildMetadataIdentifier {
57-
result = (result &* mul) ^ UInt64(build.hashValue)
57+
result = (result &* mul) ^ UInt64(bitPattern: Int64(build.hashValue))
5858
}
5959
return Int(bitPattern: UInt(result))
6060
}

0 commit comments

Comments
 (0)