Skip to content

Commit

Permalink
Fix #3367: Add extra validation to TransformDecimalCtorToConstant to …
Browse files Browse the repository at this point in the history
…prevent crashes with obfuscated assemblies.
  • Loading branch information
siegfriedpammer committed Jan 13, 2025
1 parent 507da70 commit b9f5090
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,15 @@ public byte Issue2166b(int x)
return (byte)(x & 0x10);
}

public decimal Issue3367()
{
#if CS70
return new decimal(0, 0, 0, isNegative: false, 29);
#else
return new decimal(0, 0, 0, false, 29);
#endif
}

private void ExpectUInt64(ulong _)
{

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ bool TransformDecimalCtorToConstant(NewObj inst, out LdcDecimal result)
int lo, mid, hi, isNegative, scale;
if (args[0].MatchLdcI4(out lo) && args[1].MatchLdcI4(out mid) &&
args[2].MatchLdcI4(out hi) && args[3].MatchLdcI4(out isNegative) &&
args[4].MatchLdcI4(out scale))
args[4].MatchLdcI4(out scale) && scale <= 28)
{
result = new LdcDecimal(new decimal(lo, mid, hi, isNegative != 0, (byte)scale));
return true;
Expand Down

0 comments on commit b9f5090

Please sign in to comment.