]> Cypherpunks repositories - gostls13.git/commitdiff
do not crash on nil data value
authorRuss Cox <rsc@golang.org>
Mon, 14 Sep 2009 23:46:48 +0000 (16:46 -0700)
committerRuss Cox <rsc@golang.org>
Mon, 14 Sep 2009 23:46:48 +0000 (16:46 -0700)
R=r
DELTA=3  (3 added, 0 deleted, 0 changed)
OCL=34606
CL=34609

src/pkg/template/template.go

index 847e58f44388264502f8e67f2100fc53db503267..46003b7671ab66c7d6367717829f9f24d1f6f523 100644 (file)
@@ -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