Skip to content

Fix infinite loop when YAML ends with colon at EOF#174

Merged
hadashiA merged 1 commit intomasterfrom
fix/tokenizer-eof-infinite-loop
Mar 9, 2026
Merged

Fix infinite loop when YAML ends with colon at EOF#174
hadashiA merged 1 commit intomasterfrom
fix/tokenizer-eof-infinite-loop

Conversation

@hadashiA
Copy link
Copy Markdown
Owner

@hadashiA hadashiA commented Mar 9, 2026

Summary

  • Fix MapValueIndent case in Utf8YamlTokenizer.ConsumeNextToken() to handle EOF after colon
  • The condition TryPeek(1, out var nextCode) && YamlCodes.IsEmpty(nextCode) returned false at EOF, causing the colon to fall through to ConsumePlainScalar() and trigger an infinite loop in ConsumeMoreTokens()
  • Aligned the pattern with BlockEntryIndent and ExplicitKeyIndent cases which already use !TryPeek(...) || YamlCodes.IsEmpty(...)

Closes #167

Test plan

  • Added MappingKeyWithColonAtEof test with 5s timeout to catch hangs
  • All existing tests pass

🤖 Generated with Claude Code

When a YAML stream ends with a mapping value indicator (:) with no
following content or newline, TryPeek returned false causing the colon
to be misclassified as a plain scalar, leading to an infinite loop.
Now treat EOF after colon as a valid mapping value indicator. (fixes #167)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@hadashiA hadashiA merged commit 6a22361 into master Mar 9, 2026
1 check passed
@hadashiA hadashiA deleted the fix/tokenizer-eof-infinite-loop branch March 9, 2026 15:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Infinite loop in Utf8YamlTokenizer.ConsumeMoreTokens

1 participant