Closed
Description
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/[email protected]/any.go:315 +0x29
Metadata
Metadata
Assignees
Labels
No labels