Skip to content

Commit

Permalink
Fix OSEncoding math overflow (dotnet#110796)
Browse files Browse the repository at this point in the history
Discovered by @GrabYourPitchforks
  • Loading branch information
MichalPetryka authored Dec 20, 2024
1 parent 208b974 commit cf4d2b0
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/libraries/Common/src/System/Text/OSEncoding.Windows.cs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ public override int GetMaxCharCount(int byteCount)
{
ArgumentOutOfRangeException.ThrowIfNegative(byteCount);

long charCount = byteCount * 4; // Max possible value for all encodings
long charCount = (long)byteCount * 4; // Max possible value for all encodings

if (charCount > 0x7fffffff)
throw new ArgumentOutOfRangeException(nameof(byteCount), SR.ArgumentOutOfRange_GetCharCountOverflow);
Expand Down

0 comments on commit cf4d2b0

Please sign in to comment.