From 9f8ca234489c677193efb409fef485ce4774e8c6 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 23 Feb 2022 14:30:35 +0000 Subject: Fix [cb90038a63]: signed integer overflow during expr-34.22, expr-36.22 --- generic/tclExecute.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/generic/tclExecute.c b/generic/tclExecute.c index 97ac1f0..b96eab4 100644 --- a/generic/tclExecute.c +++ b/generic/tclExecute.c @@ -6286,7 +6286,8 @@ TEBCresume( (lResult * l2 != l1)) { lResult -= 1; } - lResult = l1 - l2*lResult; + lResult = (long)((unsigned long)l1 - + (unsigned long)l2*(unsigned long)lResult); goto longResultOfArithmetic; } break; @@ -8544,7 +8545,8 @@ ExecuteExtendedBinaryMathOp( && (wQuotient * w2 != w1)) { wQuotient -= (Tcl_WideInt) 1; } - wRemainder = w1 - w2*wQuotient; + wRemainder = (Tcl_WideInt)((Tcl_WideUInt)w1 - + (Tcl_WideUInt)w2*(Tcl_WideUInt)wQuotient); WIDE_RESULT(wRemainder); } -- cgit v0.12