Skip to content

Guard rfl::yaml::Reader against recursive aliases and out-of-bounds literal marks - #41

Closed
clockblocker wants to merge 1 commit into
mainfrom
yaml-recursive-alias-guard
Closed

clockblocker wants to merge 1 commit into
mainfrom
yaml-recursive-alias-guard

Conversation

@clockblocker

Copy link
Copy Markdown
Owner

Part 1 of 5 (split from #40).

Summary

  • Adds an out-of-line thread-local RAII guard (Reader::ActiveNodeGuard in src/rfl/yaml/Reader.cpp) used by read_object and read_array so cyclic YAML aliases return an rfl::Error instead of overflowing the stack.
  • Keeps const rfl::yaml::Reader stateless and thread-safe while still allowing non-cyclic (DAG) alias reuse.
  • Bounds-checks YAML::Mark::pos before indexing yaml_str_ when trimming trailing newlines on literal block scalars.
  • Adds focused tests in tests/yaml/test_recursive_alias.cpp.

Verification

  • Verified reflect-cpp-yaml-tests (68/68 at this commit; 630/630 full suite and 85/85 shared-library hidden-visibility tests at stack top) plus C++20/C++23 self-contained header checks.

…iteral marks

Track ancestor YAML nodes via a thread-local RAII guard (ActiveNodeGuard in
src/rfl/yaml/Reader.cpp) across read_object and read_array so cyclic YAML
aliases return an rfl::Error instead of overflowing the stack, while keeping
const Reader instances thread-safe and allowing non-cyclic (DAG) alias reuse.

Also bounds-check YAML::Mark::pos before indexing yaml_str_ when trimming
trailing newlines on literal block scalars.
@clockblocker

Copy link
Copy Markdown
Owner Author

Combined with #42 (2 semantic commits off main).

@clockblocker
clockblocker deleted the yaml-recursive-alias-guard branch November 25, 2026 11:28
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