]> git.kaiwu.me - quickjs.git/commitdiff
fixed potential bug in 32 bit JS_ToBigInt64() (cannot happen with canonicalized bigints)
authorFabrice Bellard <fabrice@bellard.org>
Mon, 28 Sep 2026 09:29:38 +0000 (11:29 +0200)
committerFabrice Bellard <fabrice@bellard.org>
Mon, 28 Sep 2026 09:29:38 +0000 (11:29 +0200)
quickjs.c

index 6d1dfd8fa6ebd69462035f66689dda5ca4f58c42..3fc0fde5452a77af7634b7224dfb5fe6abcbb69b 100644 (file)
--- a/quickjs.c
+++ b/quickjs.c
@@ -14752,8 +14752,11 @@ static int JS_ToBigInt64Free(JSContext *ctx, int64_t *pres, JSValue val)
         /* return the value mod 2^64 */
         res = p->tab[0];
 #if JS_LIMB_BITS == 32
-        if (p->len >= 2)
+        if (p->len >= 2) {
             res |= (uint64_t)p->tab[1] << 32;
+        } else {
+            res = (js_slimb_t)res;
+        }
 #endif
         JS_FreeValue(ctx, val);
     }