This repository was archived by the owner on Jan 23, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +6
-3
lines changed Expand file tree Collapse file tree 3 files changed +6
-3
lines changed Original file line number Diff line number Diff line change 12
12
13
13
<PropertyGroup >
14
14
<!-- Central place to set the versions of all nuget packages produced in the repo -->
15
- <PackageVersion Condition =" '$(PackageVersion)' == ''" >2.1.19 </PackageVersion >
15
+ <PackageVersion Condition =" '$(PackageVersion)' == ''" >2.1.20 </PackageVersion >
16
16
17
17
<!-- Set the boolean below to true to generate packages with stabilized versions -->
18
18
<StabilizePackageVersion Condition =" '$(StabilizePackageVersion)' == ''" >false</StabilizePackageVersion >
Original file line number Diff line number Diff line change @@ -312,8 +312,11 @@ public virtual String ReadString()
312
312
if ( currPos == 0 && n == stringLength )
313
313
return new String ( _charBuffer , 0 , charsRead ) ;
314
314
315
+ // Since we could be reading from an untrusted data source, limit the initial size of the
316
+ // StringBuilder instance we're about to get or create. It'll expand automatically as needed.
317
+
315
318
if ( sb == null )
316
- sb = StringBuilderCache . Acquire ( stringLength ) ; // Actual string length in chars may be smaller.
319
+ sb = StringBuilderCache . Acquire ( Math . Min ( stringLength , StringBuilderCache . MAX_BUILDER_SIZE ) ) ; // Actual string length in chars may be smaller.
317
320
sb . Append ( _charBuffer , 0 , charsRead ) ;
318
321
currPos += n ;
319
322
} while ( currPos < stringLength ) ;
Original file line number Diff line number Diff line change @@ -41,7 +41,7 @@ internal static class StringBuilderCache
41
41
// The value 360 was chosen in discussion with performance experts as a compromise between using
42
42
// as litle memory (per thread) as possible and still covering a large part of short-lived
43
43
// StringBuilder creations on the startup path of VS designers.
44
- private const int MAX_BUILDER_SIZE = 360 ;
44
+ internal const int MAX_BUILDER_SIZE = 360 ;
45
45
46
46
[ ThreadStatic ]
47
47
private static StringBuilder CachedInstance ;
You can’t perform that action at this time.
0 commit comments