From 8f6489861f8278f5542a7009642edba41dcb86c9 Mon Sep 17 00:00:00 2001 From: Eric Gallager Date: Thu, 19 Sep 2024 18:19:50 -0400 Subject: [PATCH] Fix code scanning alert #32: Incorrect conversion between integer types Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> --- libgo/go/net/netip/netip.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libgo/go/net/netip/netip.go b/libgo/go/net/netip/netip.go index 5faf5b0dfda36..ea42e11f0aea8 100644 --- a/libgo/go/net/netip/netip.go +++ b/libgo/go/net/netip/netip.go @@ -1262,6 +1262,9 @@ func PrefixFrom(ip Addr, bits int) Prefix { if bits < 0 || bits > ip.BitLen() || bits < math.MinInt16 || bits > math.MaxInt16 { bits = invalidPrefixBits } + if bits < math.MinInt16 || bits > math.MaxInt16 { + bits = invalidPrefixBits + } b16 := int16(bits) return Prefix{ ip: ip.withoutZone(),