Skip to content

text/template: calling .Parse on an uninitialized template panics #11226

@mwhudson

Description

@mwhudson

I found this in the tests of an old version of go.crypto:

mwhudson@glamdring:~$ cat repro.go
package main

import "text/template"

var tmpl template.Template

func main() {
    tmpl.Parse("")
}
mwhudson@glamdring:~$ go version
go version devel +348f191 Tue Jun 16 10:43:54 2015 +1200 linux/amd64
mwhudson@glamdring:~$ go run repro.go
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x0 pc=0x468f41]

goroutine 1 [running]:
text/template.(*Template).Parse(0x642a60, 0x0, 0x0, 0x7f8a9d0d00a8, 0x0, 0x0)
    /opt/opensource/go/src/text/template/template.go:180 +0x361
main.main()
    /home/mwhudson/repro.go:8 +0x2f
exit status 2
mwhudson@glamdring:~$ ~/go1.4/bin/go run repro.go

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions