Skip to content

Panics on truncated input #20

@tv42

Description

@tv42
$ ls
gencode.schema  main.go
$ cat main.go 
package main

//go:generate gencode go -schema gencode.schema

func main() {
	var x Foo
	x.Unmarshal([]byte{})
}
$ cat gencode.schema 
struct Foo {
  Bar byte
}
$ go generate
$ go run main.go gencode.schema.gen.go 
panic: runtime error: index out of range

goroutine 1 [running]:
main.(*Foo).Unmarshal(...)
	/home/tv/go/src/eagain.net/2018/gencode-bug/gencode.schema.gen.go:45
main.main()
	/home/tv/go/src/eagain.net/2018/gencode-bug/main.go:7 +0x11
exit status 2
$ 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions