summaryrefslogtreecommitdiff
path: root/load.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-06-01 13:05:54 (GMT)
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-06-01 13:05:54 (GMT)
commitb9f5cab23a086e864c1f7ec420faee7f77245e53 (patch)
tree0784302d942f726821bb54a64306a4c5ce26d191 /load.c
parent31e6dfee6c066ebfe82d5898b00924f112285331 (diff)
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
Diffstat (limited to 'load.c')
-rw-r--r--load.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/load.c b/load.c
index 75ac4df..13f3bf4 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;
}