Update JsonTextReader.cs

We are doubling the _chars.Length when calculation newArrayLength, thus it's worth to check if we are not out of int.MaxValue.
This fix allows to work on bigger files.
This commit is contained in:
Tomasz Romaszkiewicz
2017-10-06 19:47:30 +02:00
committed by GitHub
parent 6057d9b831
commit 17f055e944
+1 -1
View File
@@ -240,7 +240,7 @@ namespace Newtonsoft.Json
// once in the last 10% of the buffer shift the remaining content to the start to avoid
// unnecessarily increasing the buffer size when reading numbers/strings
int length = _chars.Length;
if (length - _charPos <= length * 0.1)
if (length - _charPos <= length * 0.1 || length > int.MaxValue / 2 - 1)
{
int count = _charsUsed - _charPos;
if (count > 0)