Skip to content

fix: prevent infinite loops in collection deserialization by skipping unexpected tokens#5

Merged
glucaci merged 1 commit into
mainfrom
fix-infinite-loop
Jan 5, 2026
Merged

fix: prevent infinite loops in collection deserialization by skipping unexpected tokens#5
glucaci merged 1 commit into
mainfrom
fix-infinite-loop

Conversation

@glucaci
Copy link
Copy Markdown
Member

@glucaci glucaci commented Jan 5, 2026

This pull request improves the robustness of collection and dictionary deserialization in the YAML source generator by ensuring the reader properly skips unexpected tokens, preventing potential infinite loops. It also enhances the Skip() method in the YAML reader to correctly handle scalar values.

Error handling and infinite loop prevention:

  • Updated code generation in YamlSourceGenerator.cs for reading mappings, sequences, and dictionaries to call reader.Skip() when an unexpected token is encountered, avoiding infinite loops during deserialization. [1] [2] [3]

Reader behavior improvements:

  • Enhanced the Skip() method in Utf8YamlReader.cs to advance the reader when encountering scalar tokens (including nulls), ensuring scalars are properly skipped and not misinterpreted as structural tokens.

@glucaci glucaci merged commit d1bab84 into main Jan 5, 2026
1 check passed
@glucaci glucaci deleted the fix-infinite-loop branch January 5, 2026 16:19
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.

1 participant