From 548c7cb9f517dcb8029bd9698187c81819e08edd Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Wed, 29 May 2024 11:07:07 -0700 Subject: merge revision(s) 7e4b1f8e1935a10df3c41ee60ca0987d73281126: [Backport #20322] [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`. --- string.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'string.c') diff --git a/string.c b/string.c index cae234687d..3d4650ff05 100644 --- a/string.c +++ b/string.c @@ -12092,7 +12092,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); } -- cgit v1.2.3