-
Notifications
You must be signed in to change notification settings - Fork 5.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug #20322] Fix rb_enc_interned_str_cstr null encoding #10169
Conversation
The documentation for `rb_enc_interned_str_cstr` notes that `enc` can be a null pointer, but this currently causes a segmentation fault when trying to autoload the encoding. This commit fixes the issue by checking for NULL before calling `rb_enc_autoload`.
Launchable Report❌ Test session #2679418 failed ❌ Test session #2679429 failed Passed test sessions✅ Test session #2679416 passed Build: refs_pull_10169_merge_039a1129ab55b887a1721baecb366998f4d05c69 |
Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
This commit adds support for a null pointer to be passed as the encoding argument to rb_enc_interned_str_cstr. When we implemented this function originally, we noticed that the CRuby behavior did not match the header documentation, so we opted not to support it. However, this has now been fixed in CRuby [1], so we can fix it here as well. [1]: ruby/ruby#10169
This commit adds support for a null pointer to be passed as the encoding argument to rb_enc_interned_str_cstr. When we implemented this function originally, we noticed that the CRuby behavior did not match the header documentation, so we opted not to support it. However, this has now been fixed in CRuby [1], so we can fix it here as well. [1]: ruby/ruby#10169
This commit adds support for a null pointer to be passed as the encoding argument to rb_enc_interned_str_cstr. When we implemented this function originally, we noticed that the CRuby behavior did not match the header documentation, so we opted not to support it. However, this has now been fixed in CRuby [1], so we can fix it here as well. [1]: ruby/ruby#10169
This commit adds support for a null pointer to be passed as the encoding argument to rb_enc_interned_str_cstr. When we implemented this function originally, we noticed that the CRuby behavior did not match the header documentation, so we opted not to support it. However, this has now been fixed in CRuby [1], so we can fix it here as well. [1]: ruby/ruby#10169
This commit adds support for a null pointer to be passed as the encoding argument to rb_enc_interned_str_cstr. When we implemented this function originally, we noticed that the CRuby behavior did not match the header documentation, so we opted not to support it. However, this has now been fixed in CRuby [1], so we can fix it here as well. [1]: ruby/ruby#10169
https://bugs.ruby-lang.org/issues/20322
While adding support for
rb_enc_interned_str_cstr
in TruffleRuby, we noticed the documentation says thatenc
can be a null pointer:ruby/include/ruby/internal/encoding/string.h
Line 120 in 93556d4
However, this currently causes a segmentation fault when it tries to autoload the encoding because it calls
rb_enc_mbmaxlen
which expects a non-null encoding. This commit fixes the issue by checking for NULL before callingrb_enc_autoload
.I'm not sure how necessary the fix is, perhaps nobody has encountered this issue. Alternatively we could just remove the note about null pointers from the docs.