Skip to content

Commit ff720f4

Browse files
committed
1 parent b186a3b commit ff720f4

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Sources/ContainerizationEXT4/Integer+Extensions.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,12 @@ extension UInt64 {
3333
lhs % UInt64(rhs)
3434
}
3535

36+
// Bug #32 (MEDIUM): Original used (lhs / UInt64(rhs)).lo which silently discards the upper
37+
// 32 bits; if the quotient exceeds UInt32.max the result is a wrong small value with no trap.
38+
// Fixed to UInt32(lhs / UInt64(rhs)), which traps visibly on overflow.
39+
// Same fix: sonnet. All other branches use .lo — silent truncation on large quotients.
3640
public static func / (lhs: Self, rhs: UInt32) -> UInt32 {
37-
(lhs / UInt64(rhs)).lo
41+
UInt32(lhs / UInt64(rhs))
3842
}
3943

4044
public static func * (lhs: Self, rhs: UInt32) -> UInt64 {

0 commit comments

Comments
 (0)