From 17f055e9441747c7c8952cf2207dbafe0697cf0b Mon Sep 17 00:00:00 2001 From: Tomasz Romaszkiewicz Date: Fri, 6 Oct 2017 19:47:30 +0200 Subject: [PATCH] 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. --- Src/Newtonsoft.Json/JsonTextReader.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Src/Newtonsoft.Json/JsonTextReader.cs b/Src/Newtonsoft.Json/JsonTextReader.cs index e04aa0f8..8d568dbd 100644 --- a/Src/Newtonsoft.Json/JsonTextReader.cs +++ b/Src/Newtonsoft.Json/JsonTextReader.cs @@ -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)