aboutsummaryrefslogtreecommitdiffstats
path: root/internal/notify/image_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/notify/image_test.go')
-rw-r--r--internal/notify/image_test.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/internal/notify/image_test.go b/internal/notify/image_test.go
index 00dfb33..4f8c7ce 100644
--- a/internal/notify/image_test.go
+++ b/internal/notify/image_test.go
@@ -16,6 +16,7 @@ import (
"image"
"image/color"
"image/png"
+ "math"
"testing"
"github.com/godbus/dbus/v5"
@@ -161,4 +162,20 @@ func TestRawImagePNGRejectsBadData(t *testing.T) {
}).PNG(); err == nil {
t.Fatal("oversized dimensions must error")
}
+ // Small dimensions but RowStride at MaxInt: need wraps negative and the
+ // y*stride slice at y=1 panics. Must error, not panic.
+ if _, err := (&RawImage{
+ Width: 2, Height: 2, RowStride: math.MaxInt,
+ BitsPerSample: 8, Channels: 4,
+ Data: []byte{0, 0, 0, 255, 0, 0, 0, 255},
+ }).PNG(); err == nil {
+ t.Fatal("oversized rowstride must error")
+ }
+ if _, err := (&RawImage{
+ Width: 2, Height: 1, RowStride: -1,
+ BitsPerSample: 8, Channels: 4,
+ Data: []byte{0, 0, 0, 255, 0, 0, 0, 255},
+ }).PNG(); err == nil {
+ t.Fatal("negative rowstride must error")
+ }
}