ugorji / go

idiomatic codec and rpc lib for msgpack, cbor, json, etc. msgpack.org[Go]
MIT License
1.86k stars 295 forks source link

fix decoding into unaddressable arrays #267

Closed ruz closed 6 years ago

ruz commented 6 years ago

the following was failing: type Some [1]byte

to := []interface{}{Some{}}
Decode(to}

array in slice of interfaces is not addressable

ugorji commented 6 years ago

Thanks for this. I definitely appreciate your complete PR - test and fix.

Let me use the changes in the test file to reproduce the error and validate your fix. It is likely correct, but they may be a shorter solution that fits in with the codebase better.

I will follow up soon.

ugorji commented 6 years ago

The appropriate fix is slightly different.

We should already account for decoding into "values" contained into an interface. E.g. int, float32, array, etc. All these values are non-addressable.

The function that checks if a value is non-addressable had a bug in it. Fixing that bug fixed the issue.

I will run a few checks to ensure all works well across all facets of codec (fast-path, reflection path, codecgen path, etc) and should have a fix in soon after.

ruz commented 6 years ago

TY. Nice one line fix. You have quite big code base to comprehend in a few hours.