summaryrefslogtreecommitdiff
path: root/ruby.c
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2022-08-07 14:46:59 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2022-08-07 14:46:59 +0900
commitf2423be49d6f1b6ae42f542c43b8b02d5115dc0c (patch)
tree92dd9aca4c85193ed4782cae5aa6568d8ebe8fa1 /ruby.c
parent591ee9d068de174460f0e6fe81b36e7625b90f6c (diff)
downloadruby-f2423be49d6f1b6ae42f542c43b8b02d5115dc0c.tar.gz
Duplicate libruby self path
When LOAD_RELATIVE, as `sopath` is truncated to the prefix path, make the duplicate before it. Also make `rb_libruby_selfpath` frozen and hidden.
Diffstat (limited to 'ruby.c')
-rw-r--r--ruby.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/ruby.c b/ruby.c
index 991c9031de..7c6742cac4 100644
--- a/ruby.c
+++ b/ruby.c
@@ -629,7 +629,13 @@ ruby_init_loadpath(void)
#if defined(LOAD_RELATIVE) || defined(__MACH__)
VALUE libruby_path = runtime_libruby_path();
# if defined(__MACH__)
- rb_libruby_selfpath = libruby_path;
+ VALUE selfpath = libruby_path;
+# if defined(LOAD_RELATIVE)
+ selfpath = rb_str_dup(selfpath);
+# endif
+ rb_obj_hide(selfpath);
+ OBJ_FREEZE_RAW(selfpath);
+ rb_libruby_selfpath = selfpath;
rb_gc_register_address(&rb_libruby_selfpath);
# endif
#endif