We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent fa73682 commit 314b2faCopy full SHA for 314b2fa
spectrocloud/common/safe_conversions.go
@@ -9,11 +9,17 @@ func SafeUint32(value int) uint32 {
9
// On 64-bit systems, we need to check against uint32 max
10
if ^uint(0)>>32 == 0 {
11
// 32-bit system: int and uint32 have same size, no overflow possible
12
- return uint32(value)
+ if value >= 0 {
13
+ return uint32(value)
14
+ }
15
+ return 0
16
}
17
// 64-bit system: check against uint32 max
18
if uint64(value) > 0xFFFFFFFF {
19
return 0xFFFFFFFF
20
21
22
23
24
25
0 commit comments