mirror of
https://github.com/ruby/ruby.git
synced 2026-10-28 16:36:20 +08:00
The parser calls back into Ruby for every event, so a handler can call #parse again on the same object. That reinitialised the parser and re-pointed it at new input while the outer loop was still driving it, which left the outer loop reading the inner document's freed buffer, or resuming on a parser with no input at all and tripping libyaml's read_handler assertion. Psych::Exception is used so the caller can rescue it, and the in-use flag is cleared with rb_ensure so a parser stays reusable afterwards. https://github.com/ruby/psych/commit/5f2e37dc1c Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>