aboutsummaryrefslogtreecommitdiffstats
path: root/string.c
diff options
context:
space:
mode:
authorThomas Marshall <thomas@thomasmarshall.com>2024-03-03 10:43:35 +0000
committerGitHub <noreply@github.com>2024-03-03 10:43:35 +0000
commit7e4b1f8e1935a10df3c41ee60ca0987d73281126 (patch)
tree4a03894e654e309606cbdd8dfe3fa7241be6ab03 /string.c
parent93556d46203545bc2364b1c0dd1281ba098f3cc9 (diff)
downloadruby-7e4b1f8e1935a10df3c41ee60ca0987d73281126.tar.gz
[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`.
Diffstat (limited to 'string.c')
-rw-r--r--string.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/string.c b/string.c
index d9182530ed..a756523c4b 100644
--- a/string.c
+++ b/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);
}