Commits

Rob Pike  committed 311d011

text/template: fix nil crash on Templates
Fixes issue 3872.

R=golang-dev, rsc
CC=golang-dev
http://codereview.appspot.com/6612060

  • Participants
  • Parent commits 30663f5

Comments (0)

Files changed (2)

File src/pkg/text/template/exec_test.go

 		t.Errorf("expected %q got %q", expect, result)
 	}
 }
+
+func TestExecuteOnNewTemplate(t *testing.T) {
+	// This is issue 3872.
+	_ = New("Name").Templates()
+}

File src/pkg/text/template/template.go

 // Templates returns a slice of the templates associated with t, including t
 // itself.
 func (t *Template) Templates() []*Template {
+	if t.common == nil {
+		return nil
+	}
 	// Return a slice so we don't expose the map.
 	m := make([]*Template, 0, len(t.tmpl))
 	for _, v := range t.tmpl {