summaryrefslogtreecommitdiff
path: root/js/src
diff options
context:
space:
mode:
authorBrian Smith <brian@dbsoft.org>2023-07-21 14:20:11 -0500
committerBrian Smith <brian@dbsoft.org>2023-07-21 14:20:11 -0500
commit6257513c7e0e1e90b47b35e0c2ea63eeeb802ed8 (patch)
tree6557e3e7663ecc9589b53fa92ff81b423c86fd72 /js/src
parent0587c8511449705ea2827312982df834d151b72a (diff)
downloaduxp-6257513c7e0e1e90b47b35e0c2ea63eeeb802ed8.tar.gz
Issue #1240 - Part 9 - Fix incorrectly parsing decimal BigInt 0n.
The decimal parser strips leading 0s, so prevent tokenbuf being empty.
Diffstat (limited to 'js/src')
-rw-r--r--js/src/frontend/TokenStream.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/js/src/frontend/TokenStream.cpp b/js/src/frontend/TokenStream.cpp
index b2fe0afcf4..b11c7df584 100644
--- a/js/src/frontend/TokenStream.cpp
+++ b/js/src/frontend/TokenStream.cpp
@@ -1646,9 +1646,12 @@ TokenStream::getTokenInternal(TokenKind* ttp, Modifier modifier)
if (isBigInt) {
size_t length = userbuf.addressOfNextRawChar() - numStart - 1;
tokenbuf.clear();
- if(!tokenbuf.reserve(length))
+ if(!tokenbuf.reserve(length > 0 ? length : 1))
goto error;
- tokenbuf.infallibleAppend(numStart, length);
+ if(length > 0)
+ tokenbuf.infallibleAppend(numStart, length);
+ else
+ tokenbuf.infallibleAppend("0", 1);
tp->type = TOK_BIGINT;
goto out;
}