From 4a8372a709910ddaba8115a2f504c0c594b93f3a Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Wed, 1 Nov 2023 06:53:16 +0100 Subject: [PATCH] Fix UB left shift of negative number --- quickjs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quickjs.c b/quickjs.c index b0e91d0..48e9a38 100644 --- a/quickjs.c +++ b/quickjs.c @@ -34192,7 +34192,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;