From f315e440302883054d0c2bd85486878cb4f8572c Mon Sep 17 00:00:00 2001 From: monkeybutter Date: Tue, 3 Apr 2018 11:08:12 +1000 Subject: [PATCH] tiff: fixes problem with decoding tiled uint16 tiff files. The proposed fix updates the x axis offset variable in case the tile surpasses the limits of the destination image. Fixes golang/go#24657 Change-Id: I6bc52274a05dc41b058f6a6f1d0a304f1b20152d Reviewed-on: https://go-review.googlesource.com/104295 Reviewed-by: Brad Fitzpatrick Run-TryBot: Brad Fitzpatrick TryBot-Result: Gobot Gobot --- tiff/reader.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tiff/reader.go b/tiff/reader.go index 0e3d332..8a941c1 100644 --- a/tiff/reader.go +++ b/tiff/reader.go @@ -264,6 +264,9 @@ func (d *decoder) decode(dst image.Image, xmin, ymin, xmax, ymax int) error { } img.SetGray16(x, y, color.Gray16{v}) } + if rMaxX == img.Bounds().Max.X { + d.off += 2 * (xmax - img.Bounds().Max.X) + } } } else { img := dst.(*image.Gray)