Keep room in the token buffer for the terminator

tokspace stops doubling as soon as the buffer reaches the token's length,
so a copy that lands exactly on the end leaves tokfix writing its
terminator one byte past it.  No caller passes a large enough n to reach
that today, but the invariant tokfix relies on is worth holding.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Shugo Maeda 2026-07-20 19:54:25 +09:00 committed by Shugo Maeda
parent 9c7336d823
commit da37301f08
Notes: git 2026-07-20 13:49:57 +00:00

View File

@ -7728,7 +7728,7 @@ tokspace(struct parser_params *p, int n)
p->tokidx += n;
if (p->tokidx >= p->toksiz) {
do {p->toksiz *= 2;} while (p->toksiz < p->tokidx);
do {p->toksiz *= 2;} while (p->toksiz <= p->tokidx);
REALLOC_N(p->tokenbuf, char, p->toksiz);
}
return &p->tokenbuf[p->tokidx-n];