mirror of
https://github.com/golang/go
synced 2024-11-18 16:04:44 -07:00
image/draw: fix crash in clip
Fixes #9177 Change-Id: I1c7e57f0f0a9b00fb3ddc7fa4844ac53ea6df46f Reviewed-on: https://go-review.googlesource.com/1876 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
parent
01b2560068
commit
64e6fe2d29
@ -191,3 +191,13 @@ func TestClip(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestClipWithNilMP(t *testing.T) {
|
||||
src := image.NewRGBA(image.Rect(0, 0, 100, 100))
|
||||
// dst must be smaller than src for clipping to occur
|
||||
dst := image.NewRGBA(image.Rect(50, 50, 100, 100))
|
||||
r := image.Rect(0, 0, 100, 100)
|
||||
sp := image.ZP
|
||||
// issue 9177: floydSteinberg.Draw passes nil for mp, which used to cause clip to panic
|
||||
clip(dst, &r, src, &sp, nil, nil)
|
||||
}
|
||||
|
@ -83,8 +83,10 @@ func clip(dst Image, r *image.Rectangle, src image.Image, sp *image.Point, mask
|
||||
}
|
||||
(*sp).X += dx
|
||||
(*sp).Y += dy
|
||||
(*mp).X += dx
|
||||
(*mp).Y += dy
|
||||
if mp != nil {
|
||||
(*mp).X += dx
|
||||
(*mp).Y += dy
|
||||
}
|
||||
}
|
||||
|
||||
func processBackward(dst Image, r image.Rectangle, src image.Image, sp image.Point) bool {
|
||||
|
Loading…
Reference in New Issue
Block a user