mirror of
https://github.com/ruby/ruby.git
synced 2026-07-31 09:25:15 +08:00
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:
parent
9c7336d823
commit
da37301f08
Notes:
git
2026-07-20 13:49:57 +00:00
2
parse.y
2
parse.y
@ -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];
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user