mirror of
https://github.com/ruby/ruby.git
synced 2025-09-15 08:33:58 +02:00
[Bug #20322] Fix rb_enc_interned_str_cstr null encoding
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`.
This commit is contained in:
parent
93556d4620
commit
7e4b1f8e19
5 changed files with 20 additions and 4 deletions
2
string.c
2
string.c
|
@ -12122,7 +12122,7 @@ rb_interned_str_cstr(const char *ptr)
|
|||
VALUE
|
||||
rb_enc_interned_str(const char *ptr, long len, rb_encoding *enc)
|
||||
{
|
||||
if (UNLIKELY(rb_enc_autoload_p(enc))) {
|
||||
if (enc != NULL && UNLIKELY(rb_enc_autoload_p(enc))) {
|
||||
rb_enc_autoload(enc);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue