Conversation
This clamps to supported versions based on the current Ruby version.
eregon
reviewed
Jan 29, 2026
| const char *current_version = RSTRING_PTR(rb_const_get(rb_cObject, rb_intern("RUBY_VERSION"))); | ||
| if (!pm_options_version_set(options, current_version, 3)) { | ||
| rb_exc_raise(rb_exc_new_cstr(rb_cPrismCurrentVersionError, current_version)); | ||
| const char *ruby_version = RSTRING_PTR(rb_const_get(rb_cObject, rb_intern("RUBY_VERSION"))); |
Member
There was a problem hiding this comment.
Pre-existing issue but I think this pattern looks unsafe and could cause segfaults in the worst case.
The problem is getting the constant value (a Ruby String) but not keeping a reference to it on stack, then the GC might move the constant and if the char* is embedded it will move too and we'd read something else in the Ruby heap.
I think the fix is just keeping a variable with the VALUE and also use it in the rb_exc* below.
I don't have time to make a PR now though.
eregon
added a commit
to eregon/yarp
that referenced
this pull request
Jan 29, 2026
matzbot
pushed a commit
to ruby/ruby
that referenced
this pull request
Feb 3, 2026
…char* does not move * See ruby/prism#3886 (comment). ruby/prism@98603ce8cc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This clamps to supported versions based on the current Ruby version.
Fixes #3885