summaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
authorNARUSE, Yui <naruse@airemix.jp>2021-04-02 16:06:31 +0900
committerNARUSE, Yui <naruse@airemix.jp>2021-04-02 16:06:31 +0900
commit4e2738f477b5343a0d48a400c975220fed123c9b (patch)
treede0b2bc713498c3a26c3f4dac5fa0daee58b8bc5 /internal
parent855401da495117fcf5d258fe43b71010abc43d9a (diff)
merge revision(s) 7e8a9af9db42a21f6a1125a29e98c45ff9d5833b: [Backport #17732]
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 --- encoding.c | 28 ++++++++++++---------------- ext/-test-/string/depend | 3 +++ ext/-test-/string/fstring.c | 15 +++++++++++++++ internal/encoding.h | 3 +++ string.c | 4 ++++ test/-ext-/string/test_fstring.rb | 16 ++++++++++++++++ 6 files changed, 53 insertions(+), 16 deletions(-)
Diffstat (limited to 'internal')
-rw-r--r--internal/encoding.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/internal/encoding.h b/internal/encoding.h
index af236daeaf..c0cf061bd4 100644
--- a/internal/encoding.h
+++ b/internal/encoding.h
@@ -12,12 +12,15 @@
#include "ruby/ruby.h" /* for ID */
#include "ruby/encoding.h" /* for rb_encoding */
+#define rb_enc_autoload_p(enc) (!rb_enc_mbmaxlen(enc))
+
/* encoding.c */
ID rb_id_encoding(void);
rb_encoding *rb_enc_get_from_index(int index);
rb_encoding *rb_enc_check_str(VALUE str1, VALUE str2);
int rb_encdb_replicate(const char *alias, const char *orig);
int rb_encdb_alias(const char *alias, const char *orig);
+int rb_enc_autoload(rb_encoding *enc);
int rb_encdb_dummy(const char *name);
void rb_encdb_declare(const char *name);
void rb_enc_set_base(const char *name, const char *orig);