Skip to content

Commit 65536eb

Browse files
Fix potential BitCast bug for platforms without unaligned reads (#89364)
BitCast could potentially make an invalid read when reinterpreting a type to another that requires higher alignment, which could possibly cause a fault on Mono ARMv6.
1 parent ecef854 commit 65536eb

File tree

1 file changed

+1
-1
lines changed
  • src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices

1 file changed

+1
-1
lines changed

src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/Unsafe.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ public static TTo BitCast<TFrom, TTo>(TFrom source)
253253
{
254254
ThrowHelper.ThrowNotSupportedException();
255255
}
256-
return As<TFrom, TTo>(ref source);
256+
return ReadUnaligned<TTo>(ref As<TFrom, byte>(ref source));
257257
}
258258

259259
/// <summary>

0 commit comments

Comments
 (0)