From 9c0c85f17044d7040cdabc372b3e2706ec9f631b Mon Sep 17 00:00:00 2001 From: "Randall C. O'Reilly" Date: Thu, 30 Aug 2018 17:02:03 -0600 Subject: [PATCH] guard on weird index access error in glyph.go:234 --- truetype/glyph.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/truetype/glyph.go b/truetype/glyph.go index 5bb236a..ceafd42 100644 --- a/truetype/glyph.go +++ b/truetype/glyph.go @@ -6,6 +6,8 @@ package truetype import ( + "fmt" + "golang.org/x/image/font" "golang.org/x/image/math/fixed" ) @@ -231,7 +233,11 @@ func (g *GlyphBuf) load(recursion uint32, i Index, useMyMetrics bool) (err error np0, ne0 := len(g.Points), len(g.Ends) program := g.loadSimple(glyf, ne) g.addPhantomsAndScale(np0, np0, true, true) - pp1x = g.Points[len(g.Points)-4].X + idx := len(g.Points) - 4 + if idx < 0 { + return fmt.Errorf("points out of range error") + } + pp1x = g.Points[idx].X if g.hinting != font.HintingNone { if len(program) != 0 { err := g.hinter.run(