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 on nil pointers in structs #1

Closed
tom-seechange opened this issue May 10, 2022 · 2 comments
Closed

Panic on nil pointers in structs #1

tom-seechange opened this issue May 10, 2022 · 2 comments
Labels
bug Something isn't working

Comments

@tom-seechange
Copy link

Hi,

When mapping from a struct, to a struct, either of which contain nil pointers, the mapValue function will panic on the following line:

tk, fk := toRv.Type().Kind(), fromRv.Type().Kind()

This is due to a nil pointer dereference

The following code snippet skips mapValues if either side is nil:

func (m *Mapper) mapValue(toRv, fromRv reflect.Value) (returnError error) { if !toRv.IsValid() || !fromRv.IsValid() { return }

That works for me but unsure of any unintended consequences.

Thanks,

Tom

@dranikpg dranikpg added the bug Something isn't working label May 14, 2022
@dranikpg
Copy link
Owner

Hi!

Thanks for reporting the issue. This is indeed a bug

Would you mind checking out ac79c39? I hope this should fix your issues. If it does, I'll release a patch shortly

@dranikpg
Copy link
Owner

Closed by v0.1.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants