From 69526e79736a329b441461ef7456bc6f2f5ce176 Mon Sep 17 00:00:00 2001 From: nobu Date: Thu, 1 Jun 2017 13:05:54 +0000 Subject: load.c: convert by rb_get_path_check * load.c (rb_require_internal): convert to path name with the given safe level, without setting global safe level. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58987 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- load.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'load.c') diff --git a/load.c b/load.c index 75ac4df83f..13f3bf43e4 100644 --- a/load.c +++ b/load.c @@ -969,6 +969,8 @@ rb_require_internal(VALUE fname, int safe) RUBY_DTRACE_HOOK(REQUIRE_ENTRY, StringValuePtr(fname)); + fname = rb_get_path_check(fname, safe); + TH_PUSH_TAG(th); saved.safe = rb_safe_level(); if ((state = EXEC_TAG()) == 0) { @@ -976,16 +978,13 @@ rb_require_internal(VALUE fname, int safe) long handle; int found; - rb_set_safe_level_force(safe); - FilePathValue(fname); rb_set_safe_level_force(0); RUBY_DTRACE_HOOK(FIND_REQUIRE_ENTRY, StringValuePtr(fname)); - path = rb_str_encode_ospath(fname); found = search_required(path, &path, safe); - RUBY_DTRACE_HOOK(FIND_REQUIRE_RETURN, StringValuePtr(fname)); + if (found) { if (!path || !(ftptr = load_lock(RSTRING_PTR(path)))) { result = 0; @@ -1018,6 +1017,7 @@ rb_require_internal(VALUE fname, int safe) rb_set_safe_level_force(saved.safe); if (state) { + RB_GC_GUARD(fname); /* never TAG_RETURN */ return state; } -- cgit v1.2.3