From ad78f67dc23d22715d3eb98ab81ccd2c1beba1ed Mon Sep 17 00:00:00 2001 From: Nigel Tao Date: Wed, 15 Sep 2010 16:05:32 +1000 Subject: [PATCH] freetype: Fix panic when drawing a span to the right of the bounding rect. This does for Alpha{Over,Src}Painter what revision 7329234544 did for RGBAPainter. R=r CC=golang-dev http://codereview.appspot.com/2210041 --- freetype/raster/paint.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/freetype/raster/paint.go b/freetype/raster/paint.go index 85e7143..39d2e41 100644 --- a/freetype/raster/paint.go +++ b/freetype/raster/paint.go @@ -55,6 +55,9 @@ func (r AlphaOverPainter) Paint(ss []Span, done bool) { if s.X1 > b.Max.X { s.X1 = b.Max.X } + if s.X0 >= s.X1 { + continue + } base := s.Y * r.Image.Stride p := r.Image.Pix[base+s.X0 : base+s.X1] a := int(s.A >> 24) @@ -88,6 +91,9 @@ func (r AlphaSrcPainter) Paint(ss []Span, done bool) { if s.X1 > b.Max.X { s.X1 = b.Max.X } + if s.X0 >= s.X1 { + continue + } base := s.Y * r.Image.Stride p := r.Image.Pix[base+s.X0 : base+s.X1] color := image.AlphaColor{uint8(s.A >> 24)}