Skip to content

html/template: invalid memory address or nil pointer dereference #10615

Description

@dvyukov
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 = "{{.0.E}}"
panic: runtime error: invalid memory address or nil pointer dereference

goroutine 1 [running]:
text/template.errRecover(0xc208041eb0)
    src/text/template/exec.go:100 +0xb2
text/template.(*state).evalArg(0xc2080105c0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x7f01b141c210, 0xc208020120, 0x0, 0x0, ...)
    src/text/template/exec.go:667 +0x46a
text/template.(*state).evalChainNode(0xc2080105c0, 0x0, 0x0, 0x0, 0xc208010500, 0xc20800a5b0, 0x1, 0x1, 0x0, 0x0, ...)
    src/text/template/exec.go:439 +0x28a
text/template.(*state).evalCommand(0xc2080105c0, 0x0, 0x0, 0x0, 0xc208014810, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
    src/text/template/exec.go:367 +0x31d
text/template.(*state).evalPipeline(0xc2080105c0, 0x0, 0x0, 0x0, 0xc208012190, 0x0, 0x0, 0x0)
    src/text/template/exec.go:343 +0x1a0
text/template.(*state).walk(0xc2080105c0, 0x0, 0x0, 0x0, 0x7f01b141c2a0, 0xc2080148a0)
    src/text/template/exec.go:178 +0x13b
text/template.(*state).walk(0xc2080105c0, 0x0, 0x0, 0x0, 0x7f01b141c2e8, 0xc2080147e0)
    src/text/template/exec.go:186 +0x766
text/template.(*Template).Execute(0xc208010440, 0x7f01b141c1c0, 0xc20800a4c0, 0x0, 0x0, 0x0, 0x0)
    src/text/template/exec.go:141 +0x429
html/template.(*Template).Execute(0xc2080146f0, 0x7f01b141c1c0, 0xc20800a4c0, 0x0, 0x0, 0x0, 0x0)
    src/html/template/template.go:104 +0x9d
main.main()
    /tmp/htmltempl.go:13 +0x290

on commit ccc76db

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions