Skip to content

Fix SyckParser leak in Syck.compile - #66

Merged
hsbt merged 1 commit into
masterfrom
syck-compile-parser-leak
Aug 21, 2026
Merged

Fix SyckParser leak in Syck.compile#66
hsbt merged 1 commit into
masterfrom
syck-compile-parser-leak

Conversation

@hsbt

@hsbt hsbt commented Aug 21, 2026

Copy link
Copy Markdown
Member

rb_syck_compile freed its SyckParser only at the end of the function, so the rb_raise for a missing root node leaked it, as did a NoMemoryError from the result string allocation introduced in #63. Free the parser before raising, and on the normal path take ownership of the bytecode buffer from the parser's symbol table (syck_st_free_syms skips a NULLed buffer) so the parser is freed before any Ruby allocation that may raise.

rb_syck_compile freed the parser only at the end of the function, so
the rb_raise for a missing root node leaked it, as would NoMemoryError
from the result string allocation. Free the parser before raising, and
take ownership of the bytecode buffer so the parser can be freed before
building the Ruby string.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@hsbt
hsbt merged commit 3e7f271 into master Aug 21, 2026
48 checks passed
@hsbt
hsbt deleted the syck-compile-parser-leak branch August 21, 2026 02:09
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