From: Russ Cox Date: Wed, 19 Oct 2016 17:34:15 +0000 (-0400) Subject: html/template: add test case for unbounded template expansion X-Git-Tag: go1.8beta1~687 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=2693fa15ee12acd67e45d8fa57626675903ab605;p=gostls13.git html/template: add test case for unbounded template expansion Fixed by CL 31092 already, but that change is a few steps away from the problem observed here, so add an explicit test. Fixes #17019. Change-Id: If4ece1418e6596b1976961347889ce12c5969637 Reviewed-on: https://go-review.googlesource.com/31466 Run-TryBot: Russ Cox TryBot-Result: Gobot Gobot Reviewed-by: Quentin Smith --- diff --git a/src/html/template/clone_test.go b/src/html/template/clone_test.go index 069064c98b..bbe44f98dd 100644 --- a/src/html/template/clone_test.go +++ b/src/html/template/clone_test.go @@ -229,3 +229,15 @@ func TestTemplateCloneLookup(t *testing.T) { t.Error("after Clone, tmpl.Lookup(tmpl.Name()) != tmpl") } } + +func TestCloneGrowth(t *testing.T) { + tmpl := Must(New("root").Parse(`{{block "B". }}Arg{{end}}`)) + tmpl = Must(tmpl.Clone()) + Must(tmpl.Parse(`{{define "B"}}Text{{end}}`)) + for i := 0; i < 10; i++ { + tmpl.Execute(ioutil.Discard, nil) + } + if len(tmpl.DefinedTemplates()) > 200 { + t.Fatalf("too many templates: %v", len(tmpl.DefinedTemplates())) + } +}