Remove potential overflow in SafeBSTRHandle (dotnet/coreclr#10182)
authorJohn Bottenberg <jobotten@microsoft.com>
Sun, 19 Mar 2017 04:33:58 +0000 (21:33 -0700)
committerJan Kotas <jkotas@microsoft.com>
Sun, 19 Mar 2017 04:33:58 +0000 (21:33 -0700)
Commit migrated from https://github.com/dotnet/coreclr/commit/671701167d2dc8f0297f08c67482b565684d8c79

src/coreclr/src/mscorlib/src/System/Security/SafeBSTRHandle.cs

index 19d63d4..a1164dc 100644 (file)
@@ -13,7 +13,7 @@ namespace System.Security
 
         internal static SafeBSTRHandle Allocate(uint lenInChars)
         {
-            uint lenInBytes = lenInChars * sizeof(char);
+            ulong lenInBytes = (ulong)lenInChars * sizeof(char);
             SafeBSTRHandle bstr = Interop.OleAut32.SysAllocStringLen(IntPtr.Zero, lenInChars);
             if (bstr.IsInvalid) // SysAllocStringLen returns a NULL ptr when there's insufficient memory
             {