From 75ac1f1c7adf5114e53ea76935cb72750cad8c1d Mon Sep 17 00:00:00 2001 From: Taco de Wolff Date: Thu, 21 Nov 2019 16:57:06 -0300 Subject: [PATCH] Bugfix: SVG pathdata command with insufficient arguments panicked --- svg/pathdata.go | 2 +- svg/pathdata_test.go | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/svg/pathdata.go b/svg/pathdata.go index f2cdfb74da..1e90e63d64 100644 --- a/svg/pathdata.go +++ b/svg/pathdata.go @@ -82,7 +82,7 @@ func (p *PathData) ShortenPathData(b []byte) []byte { continue } else if pathCmds[c] && (cmd == 0 || cmd != c || c == 'M' || c == 'm') { // any command if cmd != 0 { - j += p.copyInstruction(b[j:], cmd) + j += p.copyInstruction(b[j:i], cmd) } else { j = i } diff --git a/svg/pathdata_test.go b/svg/pathdata_test.go index 5d09413747..023ceb6c61 100644 --- a/svg/pathdata_test.go +++ b/svg/pathdata_test.go @@ -69,6 +69,7 @@ func TestPathData(t *testing.T) { "A.0.0.4.0.0.0.3.0.0.0.0.0.4.2.0.0.0.0.2.0.4.0.0.0.4.2.8.2.0.0.0.2.9.28.0.0.0.0.0.2.3.0.0.0.0.0.0.2.3.2.09e-03.0.0.0.0.8.0.0.0.0.0.0.0", }, {"0z", "0z"}, + {"0a0z", "0a0z"}, } p := NewPathData(&Minifier{Decimals: -1})