aboutsummaryrefslogtreecommitdiff
path: root/jim.c
diff options
context:
space:
mode:
Diffstat (limited to 'jim.c')
-rw-r--r--jim.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/jim.c b/jim.c
index 58fcb84..b3eed2f 100644
--- a/jim.c
+++ b/jim.c
@@ -7047,13 +7047,18 @@ static int JimExprOpIntBin(Jim_Interp *interp, struct JimExprState *e)
unsigned long uA = (unsigned long)wA;
const unsigned int S = sizeof(unsigned long) * 8;
- wC = (unsigned long)((uA << wB) | (uA >> (S - wB)));
+ /* Shift left by the word size or more is undefined. */
+ wB %= S;
+
+ wC = (unsigned long)(uA << wB) | (uA >> (S - wB));
break;
}
case JIM_EXPROP_ROTR:{
unsigned long uA = (unsigned long)wA;
const unsigned int S = sizeof(unsigned long) * 8;
+ wB %= S;
+
wC = (unsigned long)((uA >> wB) | (uA << (S - wB)));
break;
}