• Joe Tsai's avatar
    encoding/json: always ignore embedded pointers to unexported struct types · 0cee4b7b
    Joe Tsai authored
    CL 60410 fixes a bug in reflect that allows assignments to an embedded
    field of a pointer to an unexported struct type.
    This breaks the json package because unmarshal is now unable to assign
    a newly allocated struct to such fields.
    
    In order to be consistent in the behavior for marshal and unmarshal,
    this CL changes both marshal and unmarshal to always ignore
    embedded pointers to unexported structs.
    
    Fixes #21357
    
    Change-Id: If62ea11155555e61115ebb9cfa5305caf101bde5
    Reviewed-on: https://go-review.googlesource.com/76851
    Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
    0cee4b7b
encode_test.go 23 KB