From 5764befa5ace6e2dff623a79ba5a098d36fd1a86 Mon Sep 17 00:00:00 2001 From: Rob Pike Date: Wed, 14 Jan 2015 09:13:42 +1100 Subject: text/template: protect against explicit nil in field chains An explicit nil in an expression like nil.Foo caused a panic because the evaluator attempted to reflect on the nil. A typeless nil like this cannot be used to do anything, so just error out. Fixes #9426 Change-Id: Icd2c9c7533dda742748bf161eced163991a12f54 Reviewed-on: https://go-review.googlesource.com/7643 Reviewed-by: David Symonds --- src/text/template/exec_test.go | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/text/template/exec_test.go') diff --git a/src/text/template/exec_test.go b/src/text/template/exec_test.go index 69c213ed24..b1f778797b 100644 --- a/src/text/template/exec_test.go +++ b/src/text/template/exec_test.go @@ -527,6 +527,8 @@ var execTests = []execTest{ {"bug12XE", "{{printf `%T` 0XEE}}", "int", T{}, true}, // Chained nodes did not work as arguments. Issue 8473. {"bug13", "{{print (.Copy).I}}", "17", tVal, true}, + // Didn't protect against explicit nil in field chains. + {"bug14", "{{nil.True}}", "", tVal, false}, } func zeroArgs() string { -- cgit v1.3-5-g9baa