checked
{
- if (position < 0 || numBytes < 0 || position + numBytes > byteBuffer.Length)
+ if (position < 0 || numBytes < 0 || position > byteBuffer.Length - numBytes)
{
- throw new ArgumentOutOfRangeException(nameof(byteCount));
+ throw new ArgumentOutOfRangeException(nameof(numBytes));
}
- if (index < 0 || charsRemaining < 0 || index + charsRemaining > buffer.Length)
+ if (index < 0 || charsRemaining < 0 || index > buffer.Length - charsRemaining)
{
throw new ArgumentOutOfRangeException(nameof(charsRemaining));
}
unsafe
{
fixed (byte* pBytes = byteBuffer)
+ fixed (char* pChars = buffer)
{
- fixed (char* pChars = buffer)
- {
- charsRead = m_decoder.GetChars(pBytes + position, numBytes, pChars + index, charsRemaining, false);
- }
+ charsRead = m_decoder.GetChars(pBytes + position, numBytes, pChars + index, charsRemaining, flush: false);
}
}
}
Contract.Assert(_encoding.GetMaxByteCount(1) <= 16, "_encoding.GetMaxByteCount(1) <= 16)");
int numBytes = 0;
fixed(byte * pBytes = _buffer) {
- numBytes = _encoder.GetBytes(&ch, 1, pBytes, _buffer.Length, true);
+ numBytes = _encoder.GetBytes(&ch, 1, pBytes, _buffer.Length, flush: true);
}
OutStream.Write(_buffer, 0, numBytes);
}
checked
{
- if (charStart < 0 || charCount < 0 || charStart + charCount > value.Length)
+ if (charStart < 0 || charCount < 0 || charStart > value.Length - charCount)
{
throw new ArgumentOutOfRangeException(nameof(charCount));
}