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

Fix decoding tags into nil pointers #8

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

lmars
Copy link

@lmars lmars commented Sep 11, 2017

I spotted this as I was trying to decode IPLD links into fields of type *cid.Cid, e.g:

dec := cbor.NewDecoder(...)
dec.TagDecoders[cbornode.CBORTagLink] = &cbornode.IpldLinkDecoder{}
dec.Decode(&struct { Link *cid.Cid })

which lead to the following panic:

panic: reflect: call of reflect.Value.Set on zero Value [recovered]
        panic: reflect: call of reflect.Value.Set on zero Value

Initialising the Link field so that it is not a nil pointer fixes this.

I've also run gofmt on the source files.

Signed-off-by: Lewis Marshall <lewis@lmars.net>
Signed-off-by: Lewis Marshall <lewis@lmars.net>
Signed-off-by: Lewis Marshall <lewis@lmars.net>
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

Successfully merging this pull request may close these issues.

1 participant