C#

C#

Made by DeepSource

Number of elements passed instead of buffer length CS-W1051

Bug risk
Critical
Autofix

Buffer.BlockCopy()'s last argument specifies the number of bytes to copy rather than the number of elements in the source buffer. Specifying incorrect buffer length may result in partial copying and or data loss.

Bad Practice

Buffer.BlockCopy(src, 0, dst, 0, src.Length);

Recommended

Buffer.BlockCopy(src, 0, dst, 0, Buffer.ByteLength(src));

Reference