From 7218a63a4667db4a4ce9934e01d260c30b7b1d59 Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Wed, 15 Jan 2025 21:02:59 +0100 Subject: [PATCH] #3367: Extend range check to support negative integers. --- .../IL/Transforms/EarlyExpressionTransforms.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ICSharpCode.Decompiler/IL/Transforms/EarlyExpressionTransforms.cs b/ICSharpCode.Decompiler/IL/Transforms/EarlyExpressionTransforms.cs index 2316732e90..fdfc276656 100644 --- a/ICSharpCode.Decompiler/IL/Transforms/EarlyExpressionTransforms.cs +++ b/ICSharpCode.Decompiler/IL/Transforms/EarlyExpressionTransforms.cs @@ -213,9 +213,9 @@ 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) && scale <= 28) + args[4].MatchLdcI4(out scale) && unchecked((byte)scale) <= 28) { - result = new LdcDecimal(new decimal(lo, mid, hi, isNegative != 0, (byte)scale)); + result = new LdcDecimal(new decimal(lo, mid, hi, isNegative != 0, unchecked((byte)scale))); return true; } }