scanners: avoid transient write when sentinel already NUL. · commonmark/cmark@4e47eba · GitHub
Skip to content

Commit 4e47eba

Browse files
jgmclaude
andcommitted
scanners: avoid transient write when sentinel already NUL.
_scan_at patched the byte at ptr[c->len] with '\0' around every scanner invocation so that the re2c scanners (built with yyfill:enable = 0) could use it as a stopping sentinel. In the common case the chunk is backed by a cmark_strbuf whose data[size] is already '\0', so the write was an idempotent mutation of shared backing storage. Skip it when the byte is already '\0' to preserve const-correctness and reentrancy on that path; retain the patch fallback for chunks that are not already NUL-terminated. Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 8c9dcdd commit 4e47eba

2 files changed

Lines changed: 28 additions & 6 deletions

File tree

‎src/scanners.c‎

Lines changed: 14 additions & 3 deletions

‎src/scanners.re‎

Lines changed: 14 additions & 3 deletions

0 commit comments

Comments
 (0)