@@ -38,16 +38,16 @@ public static string GetString(this Encoding encoding, ReadOnlySpan<byte> span)
38
38
#else
39
39
unsafe
40
40
{
41
- fixed ( byte * ptr = span )
41
+ fixed ( byte * ptr = & MemoryMarshal . GetReference ( span ) )
42
42
return encoding . GetString ( ptr , span . Length ) ;
43
43
}
44
44
#endif
45
45
}
46
46
47
47
public static unsafe void GetBytes ( this Encoding encoding , ReadOnlySpan < char > chars , Span < byte > bytes )
48
48
{
49
- fixed ( char * charsPtr = chars )
50
- fixed ( byte * bytesPtr = bytes )
49
+ fixed ( char * charsPtr = & MemoryMarshal . GetReference ( chars ) )
50
+ fixed ( byte * bytesPtr = & MemoryMarshal . GetReference ( bytes ) )
51
51
{
52
52
encoding . GetBytes ( charsPtr , chars . Length , bytesPtr , bytes . Length ) ;
53
53
}
@@ -57,8 +57,8 @@ public static unsafe void GetBytes(this Encoding encoding, ReadOnlySpan<char> ch
57
57
#if NET461 || NET471 || NETSTANDARD2_0
58
58
public static unsafe void Convert ( this Encoder encoder , ReadOnlySpan < char > chars , Span < byte > bytes , bool flush , out int charsUsed , out int bytesUsed , out bool completed )
59
59
{
60
- fixed ( char * charsPtr = chars )
61
- fixed ( byte * bytesPtr = bytes )
60
+ fixed ( char * charsPtr = & MemoryMarshal . GetReference ( chars ) )
61
+ fixed ( byte * bytesPtr = & MemoryMarshal . GetReference ( bytes ) )
62
62
{
63
63
// MemoryMarshal.GetNonNullPinnableReference is internal, so fake it by using an invalid but non-null pointer; this
64
64
// prevents Convert from throwing an exception when the output buffer is empty
0 commit comments