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

Panic encoding empty Any #311

Closed
vgough opened this issue Oct 4, 2018 · 0 comments
Closed

Panic encoding empty Any #311

vgough opened this issue Oct 4, 2018 · 0 comments

Comments

@vgough
Copy link

vgough commented Oct 4, 2018

If a struct contains an Any value, and the Any value is left unset, then Marshal fails with a nil pointer dereference.

eg

package main

import (
    "fmt"

    jsoniter "github.com/json-iterator/go"
)

type Foo struct {
    A jsoniter.Any
}

func main() {
    data, _ := jsoniter.Marshal(&Foo{})
    fmt.Println(string(data))
}

The SEGV occurs here:

github.com/json-iterator/go.(*directAnyCodec).Encode(0x132e3a0, 0xc00000e990, 0xc000058180)
github.com/json-iterator/go@v1.1.5/any.go:315 +0x29

@taowen taowen closed this as completed in 5916df6 Oct 24, 2018
zhenzou pushed a commit to zhenzou/jsoniter that referenced this issue Feb 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant