From 187de15e2bd4cc19b14e2a9b97ca1b12d847a2c9 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 15 Dec 2021 17:03:03 +0000 Subject: Fix [90612089d8]: signed integer overflow in ExprRandFunc() --- generic/tclBasic.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/generic/tclBasic.c b/generic/tclBasic.c index fb85241..1cc22e1 100644 --- a/generic/tclBasic.c +++ b/generic/tclBasic.c @@ -7781,15 +7781,15 @@ ExprRandFunc( * take into consideration the thread this interp is running in. */ - iPtr->randSeed = TclpGetClicks() + (PTR2INT(Tcl_GetCurrentThread())<<12); + iPtr->randSeed = TclpGetClicks() + ((unsigned long)PTR2UINT(Tcl_GetCurrentThread())*4093); /* * Make sure 1 <= randSeed <= (2^31) - 2. See below. */ - iPtr->randSeed &= (unsigned long) 0x7FFFFFFF; - if ((iPtr->randSeed == 0) || (iPtr->randSeed == 0x7FFFFFFF)) { - iPtr->randSeed ^= 123459876; + iPtr->randSeed &= 0x7FFFFFFFL; + if ((iPtr->randSeed == 0) || (iPtr->randSeed == 0x7FFFFFFFL)) { + iPtr->randSeed ^= 123459876L; } } -- cgit v0.12