diff --git a/src/libraries/Common/src/System/HexConverter.cs b/src/libraries/Common/src/System/HexConverter.cs index 0339a186f7c55d..71d7b4e8a7262e 100644 --- a/src/libraries/Common/src/System/HexConverter.cs +++ b/src/libraries/Common/src/System/HexConverter.cs @@ -145,12 +145,13 @@ private static void EncodeToUtf16_Vector128(ReadOnlySpan bytes, Span v0.StoreUnsafe(ref destRef, pos * 2); - pos += (nuint)Vector128.Count; - if (pos == (nuint)bytes.Length) + if (pos == lengthSubVector128) { return; } + pos += (nuint)Vector128.Count; + // Overlap with the current chunk for trailing elements if (pos > lengthSubVector128) {