about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorBen Noordhuis <info@bnoordhuis.nl>2023-11-01 06:53:16 +0100
committerbptato <nincsnevem662@gmail.com>2024-03-02 18:12:24 +0100
commitfe4e8e4e2d22f253270cca071b3ad3ae19a27976 (patch)
tree5d1105497ecdba240161994dfbc881804422a4c5
parent1f7c361d05281d59773d1eaab27a1bad5425bc75 (diff)
downloadchawan-fe4e8e4e2d22f253270cca071b3ad3ae19a27976.tar.gz
Fix UB left shift of negative number
-rw-r--r--lib/quickjs/quickjs.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/quickjs/quickjs.c b/lib/quickjs/quickjs.c
index 7492198f..8e691038 100644
--- a/lib/quickjs/quickjs.c
+++ b/lib/quickjs/quickjs.c
@@ -35015,7 +35015,7 @@ static int JS_WriteBigNum(BCWriterState *s, JSValueConst obj)
         e = a->expn + 3;
     else
         e = a->expn;
-    e = (e << 1) | a->sign;
+    e = (e * 2) | a->sign;
     if (e < INT32_MIN || e > INT32_MAX) {
         JS_ThrowInternalError(s->ctx, "bignum exponent is too large");
         return -1;