From 3b76f829d970b1998e35149ad0e21f0a8f54e2f0 Mon Sep 17 00:00:00 2001 From: Michael FIG Date: Thu, 29 Oct 2020 15:17:49 -0600 Subject: [PATCH] fix: prevent infinite loop when metering BigInt values --- packages/transform-metering/src/meter.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/transform-metering/src/meter.js b/packages/transform-metering/src/meter.js index 587b235a569..6d202358a7d 100644 --- a/packages/transform-metering/src/meter.js +++ b/packages/transform-metering/src/meter.js @@ -7,7 +7,7 @@ const { ceil } = Math; const ObjectConstructor = Object; // eslint-disable-next-line no-bitwise -const bigIntWord = typeof BigInt !== 'undefined' && BigInt(1 << 32); +const bigIntWord = typeof BigInt !== 'undefined' && BigInt(2) ** BigInt(64); const bigIntZero = bigIntWord && BigInt(0); // Stop deducting when we reach a negative number. @@ -99,7 +99,6 @@ export function makeAllocateMeter(maybeAbort, meter, allocateCounter = null) { remaining = -remaining; } while (remaining > bigIntZero) { - meter[c.METER_COMPUTE](undefined, throwForever); remaining /= bigIntWord; cost += 1; }