Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

html/template: nil pointer dereference #10673

Closed
dvyukov opened this issue May 3, 2015 · 2 comments
Closed

html/template: nil pointer dereference #10673

dvyukov opened this issue May 3, 2015 · 2 comments
Milestone

Comments

@dvyukov
Copy link
Member

dvyukov commented May 3, 2015

The following program crashes with panic:

package main

import (
    "html/template"
    "io/ioutil"
)

func main() {
    t, err := template.New("foo").Parse(string(data))
    if err != nil {
        return
    }
    t.Execute(ioutil.Discard, nil)
}

var data = "{{\"\"|print \"\"|.f \"\"}}"
panic: runtime error: invalid memory address or nil pointer dereference

goroutine 1 [running]:
html/template.ensurePipelineContains(0x2083920a0, 0x20833eae0, 0x1, 0x3)
    src/html/template/escape.go:265 +0x1674
html/template.(*escaper).commit(0x208367d20)
    src/html/template/escape.go:749 +0x36c
html/template.escapeTemplate(0x20833e660, 0x22084e13d0, 0x20833e750, 0x1be2c0, 0x3, 0x0, 0x0)
    src/html/template/escape.go:39 +0x46c
html/template.(*Template).escape(0x20833e660, 0x0, 0x0)
    src/html/template/template.go:85 +0x389
html/template.(*Template).Execute(0x20833e660, 0x22084e1288, 0x2083363c0, 0x0, 0x0, 0x0, 0x0)
    src/html/template/template.go:101 +0x37
main.main()
    test.go:13 +0x25a

go version devel +fbb4c74 Sat May 2 02:48:32 2015 +0000 darwin/amd64

@dvyukov dvyukov added this to the Go1.5 milestone May 3, 2015
@dspezia
Copy link
Contributor

dspezia commented May 6, 2015

The syntax of the template is correct, since .f can be a method. This issue can be caught at execution time. Mailing a CL.

@gopherbot
Copy link

CL https://golang.org/cl/9801 mentions this issue.

@robpike robpike closed this as completed in 91d989e May 8, 2015
@golang golang locked and limited conversation to collaborators Jun 25, 2016
@rsc rsc unassigned robpike Jun 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants