Most of the invalid usages due to the conversion from uintptr to
unsafe.Pointer. In general, unsafe.Pointer(p) where p of type uintptr is
considered unsafe.
To fix that, use &p instead of p, then introduce another dereference.
Example, the invalid usage:
*(*int)(unsafe.Pointer(p)) = int(v)
wil become:
**(**int)(unsafe.Pointer(&p)) = int(v)
Closes#53
There're some problem with current usage of reflect.SliceHeader.
First, it violates the unsafe pointer conversion (rule 6th), that said,
reflect.SliceHeader must not used as plain struct.
Second, the lowest version that go-json supports, go1.12, reflect
package did not use SliceHeader in typedslicecopy, but use the safety
version. There's no reason that go-json continue using them.
See:
- https://golang.org/pkg/unsafe/#Pointer
- https://github.com/golang/go/blob/release-branch.go1.12/src/reflect/value.go#L2702