From: Russ Cox Date: Mon, 14 Sep 2009 23:46:48 +0000 (-0700) Subject: do not crash on nil data value X-Git-Tag: weekly.2009-11-06~587 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=b198b994a10feab2597ea938f7d616266bc99c92;p=gostls13.git do not crash on nil data value R=r DELTA=3 (3 added, 0 deleted, 0 changed) OCL=34606 CL=34609 --- diff --git a/src/pkg/template/template.go b/src/pkg/template/template.go index 847e58f443..46003b7671 100644 --- a/src/pkg/template/template.go +++ b/src/pkg/template/template.go @@ -575,6 +575,9 @@ func (st *state) findVar(s string) reflect.Value { for i := 0; i < len(elems); i++ { // Look up field; data must be a struct. data = reflect.Indirect(data); + if data == nil { + return nil + } typ, ok := data.Type().(*reflect.StructType); if !ok { return nil