Skip to content

Commit 8fc5f09

Browse files
committed
fix: silent failure on dst image type different than *image.NRGBA
1 parent cdc7507 commit 8fc5f09

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

stackblur.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ var shgTable = []uint32{
5353
24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
5454
}
5555

56-
// Process takes the source image and returns it's blurred version by applying the blur radius defined as parameter.
56+
// Process takes the source image and returns it's blurred version by applying the blur radius defined as parameter. The destination image must be a image.NRGBA.
5757
func Process(dst, src image.Image, radius uint32) error {
5858
// Limit the maximum blur radius to 255 to avoid overflowing the multable.
5959
if int(radius) >= len(mulTable) {
@@ -64,10 +64,12 @@ func Process(dst, src image.Image, radius uint32) error {
6464
return errors.New("blur radius must be greater than 0")
6565
}
6666

67-
if img, ok := dst.(*image.NRGBA); ok {
68-
process(img, src, radius)
67+
img, ok := dst.(*image.NRGBA)
68+
if !ok {
69+
return errors.New("the destination image must be image.NRGBA")
6970
}
7071

72+
process(img, src, radius)
7173
return nil
7274
}
7375

0 commit comments

Comments
 (0)