• Daniel Martí's avatar
    text/template: never call reflect.Zero(nil) · 618f88d8
    Daniel Martí authored
    It makes no sense to try to get the zero value of a nil type, hence the
    panic. When we have a nil type, use reflect.ValueOf(nil) instead.
    
    This was showing itself if one used a missing field on the data between
    parentheses, when the data was a nil interface:
    
    	t := template.Must(template.New("test").Parse(`{{ (.).foo }}`))
    	var v interface{}
    	t.Execute(os.Stdout, v)
    
    Resulting in:
    
    	panic: reflect: Zero(nil) [recovered]
    		panic: reflect: Zero(nil)
    
    Fixes #21171.
    
    Change-Id: Ifcc4a0c67e6df425b65bc9f82fde6fcf03828579
    Reviewed-on: https://go-review.googlesource.com/84482
    Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    Reviewed-by: 's avatarRob Pike <r@golang.org>
    618f88d8
Name
Last commit
Last update
.github Loading commit data...
api Loading commit data...
doc Loading commit data...
lib/time Loading commit data...
misc Loading commit data...
src Loading commit data...
test Loading commit data...
.gitattributes Loading commit data...
.gitignore Loading commit data...
AUTHORS Loading commit data...
CONTRIBUTING.md Loading commit data...
CONTRIBUTORS Loading commit data...
LICENSE Loading commit data...
PATENTS Loading commit data...
README.md Loading commit data...
favicon.ico Loading commit data...
robots.txt Loading commit data...