diff options
author | Jean Boussier <[email protected]> | 2021-03-19 11:29:06 +0100 |
---|---|---|
committer | Nobuyoshi Nakada <[email protected]> | 2021-03-22 21:37:48 +0900 |
commit | 7e8a9af9db42a21f6a1125a29e98c45ff9d5833b (patch) | |
tree | 67c6fe4c12f8d4fdc8365a33ebee6bc37750c157 /string.c | |
parent | 5b272a645322c2ffe0f73c523d64832678d0de5f (diff) |
rb_enc_interned_str: handle autoloaded encodings
If called with an autoloaded encoding that was not yet
initialized, `rb_enc_interned_str` would crash with
a NULL pointer exception.
See: https://github.com/ruby/ruby/pull/4119#issuecomment-800189841
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/4290
Diffstat (limited to 'string.c')
-rw-r--r-- | string.c | 4 |
1 files changed, 4 insertions, 0 deletions
@@ -11498,6 +11498,10 @@ 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))) { + rb_enc_autoload(enc); + } + struct RString fake_str; return register_fstring(rb_setup_fake_str(&fake_str, ptr, len, enc), TRUE); } |