commit 8d5c41fc538cba48221ef9d8ba9b852e9f04240f
parent e053297ac9f910a620a4c1e6bc9a5169e08d8d41
Author: Ben Noordhuis <info@bnoordhuis.nl>
Date: Wed, 1 Nov 2023 06:53:16 +0100
Fix UB left shift of negative number
Diffstat:
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/quickjs/quickjs.c b/quickjs/quickjs.c
@@ -35098,7 +35098,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;