summaryrefslogtreecommitdiffstats
path: root/generic/tclBasic.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2021-12-16 08:20:53 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2021-12-16 08:20:53 (GMT)
commite99a84db0a4d3415dad46208b2bf64a45a6dd23b (patch)
treeb825a3eb22cae3e86ae9d25c730e878f345e31bd /generic/tclBasic.c
parentb95cae5898b3abfb286c5bd99cb00bdd14049eb7 (diff)
parent187de15e2bd4cc19b14e2a9b97ca1b12d847a2c9 (diff)
downloadtcl-e99a84db0a4d3415dad46208b2bf64a45a6dd23b.zip
tcl-e99a84db0a4d3415dad46208b2bf64a45a6dd23b.tar.gz
tcl-e99a84db0a4d3415dad46208b2bf64a45a6dd23b.tar.bz2
Fix [90612089d8]: signed integer overflow in ExprRandFunc()
Diffstat (limited to 'generic/tclBasic.c')
-rw-r--r--generic/tclBasic.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/generic/tclBasic.c b/generic/tclBasic.c
index fb85241..875fec5 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() + PTR2UINT(Tcl_GetCurrentThread())*4093U;
/*
* 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;
}
}