aboutsummaryrefslogtreecommitdiff
path: root/src/text/template/exec.go
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2017-01-27 14:14:05 -0500
committerRuss Cox <rsc@golang.org>2017-02-09 14:58:40 +0000
commit06637fb3146cd7fd19efc7463cd9d2c0006bff67 (patch)
treee9d2145a1bef03a7b14988e401b4f32069f14446 /src/text/template/exec.go
parente4371fb179ad69cbd057f2430120843948e09f2f (diff)
downloadgo-06637fb3146cd7fd19efc7463cd9d2c0006bff67.tar.xz
text/template: fix method lookup on addressable nil pointer
Fixes #18816. Change-Id: I4f8f1cac2680dbde492c56d3a5a038577605e7c1 Reviewed-on: https://go-review.googlesource.com/36542 Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Rob Pike <r@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/text/template/exec.go')
-rw-r--r--src/text/template/exec.go2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/text/template/exec.go b/src/text/template/exec.go
index 7d92bd9d36..0e517a6ec3 100644
--- a/src/text/template/exec.go
+++ b/src/text/template/exec.go
@@ -551,7 +551,7 @@ func (s *state) evalField(dot reflect.Value, fieldName string, node parse.Node,
// Unless it's an interface, need to get to a value of type *T to guarantee
// we see all methods of T and *T.
ptr := receiver
- if ptr.Kind() != reflect.Interface && ptr.CanAddr() {
+ if ptr.Kind() != reflect.Interface && ptr.Kind() != reflect.Ptr && ptr.CanAddr() {
ptr = ptr.Addr()
}
if method := ptr.MethodByName(fieldName); method.IsValid() {