Skip to content

SpanHelpers.ClearWithoutReferences has several invalid (unaligned) casts #26654

@GrabYourPitchforks

Description

@GrabYourPitchforks

https://github.com/dotnet/corefx/blob/c86814f6b2ab6fee0848433bc379fba479041c0c/src/Common/src/CoreLib/System/SpanHelpers.cs#L45

It is invalid to reinterpret cast a ref byte to a ref ushort/uint/ulong without first checking the alignment of the input buffer. This could cause problems on future architectures or IOT devices where unaligned reads incur faults. This code should pin and check alignment or should use Unsafe.WriteUnaligned instead.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions