[interp] Use correctly-sized writes and reads in Unsafe.AddByteOffset and Unsafe...
commit561b400baa6322dcb3fb6d2b92bd48513fab79f7
authorimhameed <50922266+imhameed@users.noreply.github.com>
Thu, 18 Jul 2019 18:16:46 +0000 (18 11:16 -0700)
committermonojenkins <jo.shields+jenkins@xamarin.com>
Thu, 18 Jul 2019 18:16:46 +0000 (18 14:16 -0400)
treee703aaec21c285e9ecfd2b30a7df18e72b6c09d1
parentab4eca1785672ae9e2aa4930ea45e61a5743aa11
[interp] Use correctly-sized writes and reads in Unsafe.AddByteOffset and Unsafe.ByteOffset (#15677)

[interp] Use correctly-sized writes and reads in Unsafe.AddByteOffset and Unsafe.ByteOffset

The truncated store to the top of the stack in`MINT_INTRINS_UNSAFE_BYTE_OFFSET` could cause the upper bytes of the address used as the first argument to `ByteOffset` to linger, yielding inaccurate (and usually excessively large) offsets on systems where `sizeof(void *) > sizeof(guint32)`; this made
`System.Text.Unicode.Utf8Utility.GetPointerToFirstInvalidByte` return nonsense results.

The truncation in `MINT_INTRINS_UNSAFE_ADD_BYTE_OFFSET` hasn't, as far as I know, caused any test failures. But `AddByteOffset` takes an `IntPtr` as its second argument, not an `int`.

Fixes #14847.
mono/mini/interp/interp.c