Skip to content

Commit

Permalink
Fix potential BitCast bug for platforms without unaligned reads (#89364)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
MichalPetryka authored Jul 23, 2023
1 parent ecef854 commit 65536eb
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ public static TTo BitCast<TFrom, TTo>(TFrom source)
{
ThrowHelper.ThrowNotSupportedException();
}
return As<TFrom, TTo>(ref source);
return ReadUnaligned<TTo>(ref As<TFrom, byte>(ref source));
}

/// <summary>
Expand Down

0 comments on commit 65536eb

Please sign in to comment.