Fix cast in CacheMemoryMonitor (dotnet/corefx#41776)
authorStephen Toub <stoub@microsoft.com>
Tue, 15 Oct 2019 13:21:25 +0000 (09:21 -0400)
committerGitHub <noreply@github.com>
Tue, 15 Oct 2019 13:21:25 +0000 (09:21 -0400)
Avoid overflow.

Commit migrated from https://github.com/dotnet/corefx/commit/6b2cb3a16a717b47c72c088d073a8f598bfc9335

src/libraries/System.Runtime.Caching/src/System/Runtime/Caching/CacheMemoryMonitor.cs

index f9e6727..5187c44 100644 (file)
@@ -235,7 +235,7 @@ namespace System.Runtime.Caching
 
         internal void SetLimit(int cacheMemoryLimitMegabytes)
         {
-            long cacheMemoryLimit = cacheMemoryLimitMegabytes << MEGABYTE_SHIFT;
+            long cacheMemoryLimit = ((long)cacheMemoryLimitMegabytes) << MEGABYTE_SHIFT;
             _memoryLimit = cacheMemoryLimit != 0 ?
                 cacheMemoryLimit :
                 EffectiveProcessMemoryLimit;