allow overflow in imaging

This commit is contained in:
tobi 2024-09-02 15:08:07 +02:00 committed by kim
parent d5988bf8aa
commit 290f91c323

View file

@ -514,9 +514,6 @@ func (s *scanner) scan(x1, y1, x2, y2 int, dst []uint8) {
} else { } else {
r = ^(r >> 31) r = ^(r >> 31)
} }
if r > math.MaxUint8 {
panic("overflow r")
}
g := yy1 - 22554*cb1 - 46802*cr1 g := yy1 - 22554*cb1 - 46802*cr1
if uint32(g)&0xff000000 == 0 { //nolint:gosec if uint32(g)&0xff000000 == 0 { //nolint:gosec
@ -524,9 +521,6 @@ func (s *scanner) scan(x1, y1, x2, y2 int, dst []uint8) {
} else { } else {
g = ^(g >> 31) g = ^(g >> 31)
} }
if g > math.MaxUint8 {
panic("overflow g")
}
b := yy1 + 116130*cb1 b := yy1 + 116130*cb1
if uint32(b)&0xff000000 == 0 { //nolint:gosec if uint32(b)&0xff000000 == 0 { //nolint:gosec
@ -534,9 +528,6 @@ func (s *scanner) scan(x1, y1, x2, y2 int, dst []uint8) {
} else { } else {
b = ^(b >> 31) b = ^(b >> 31)
} }
if b > math.MaxUint8 {
panic("overflow b")
}
d := dst[j : j+4 : j+4] d := dst[j : j+4 : j+4]
d[0] = uint8(r) // #nosec G115 -- Overflow desired. d[0] = uint8(r) // #nosec G115 -- Overflow desired.