graphics: Bug fix: unexpected panic at Set with an out-of-range position

This commit is contained in:
Hajime Hoshi 2019-10-12 02:28:55 +09:00
parent cbe4844fa0
commit 1b011e3864
2 changed files with 2 additions and 1 deletions

View File

@ -408,7 +408,7 @@ func (img *Image) Set(x, y int, clr color.Color) {
if img.isDisposed() { if img.isDisposed() {
return return
} }
if img.isSubImage() && !image.Pt(x, y).In(img.bounds) { if !image.Pt(x, y).In(img.Bounds()) {
return return
} }
if img.isSubImage() { if img.isSubImage() {

View File

@ -1439,6 +1439,7 @@ func TestImageSet(t *testing.T) {
{1, 2}: {3, 4, 5, 6}, {1, 2}: {3, 4, 5, 6},
{7, 8}: {9, 10, 11, 12}, {7, 8}: {9, 10, 11, 12},
{13, 14}: {15, 16, 17, 18}, {13, 14}: {15, 16, 17, 18},
{-1, -1}: {19, 20, 21, 22},
} }
for p, c := range colors { for p, c := range colors {