Issue #1240 - Part 9 - Fix incorrectly parsing decimal BigInt 0n. The decimal parser strips leading 0s, so prevent tokenbuf being empty.

This commit is contained in:
Brian Smith 2023-07-21 14:20:11 -05:00 committed by roytam1
commit 4aa193b16b

View file

@ -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;
}