summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--file.c2
-rw-r--r--internal.h1
-rw-r--r--load.c8
3 files changed, 6 insertions, 5 deletions
diff --git a/file.c b/file.c
index 2af6b75874..71bc0ba8cf 100644
--- a/file.c
+++ b/file.c
@@ -200,7 +200,7 @@ rb_get_path_check_convert(VALUE obj, VALUE tmp, int level)
return rb_str_new4(tmp);
}
-static VALUE
+VALUE
rb_get_path_check(VALUE obj, int level)
{
VALUE tmp = rb_get_path_check_to_string(obj, level);
diff --git a/internal.h b/internal.h
index 62b2664ebb..a4136e29e5 100644
--- a/internal.h
+++ b/internal.h
@@ -1168,6 +1168,7 @@ VALUE rb_file_expand_path_fast(VALUE, VALUE);
VALUE rb_file_expand_path_internal(VALUE, VALUE, int, int, VALUE);
VALUE rb_get_path_check_to_string(VALUE, int);
VALUE rb_get_path_check_convert(VALUE, VALUE, int);
+VALUE rb_get_path_check(VALUE, int);
void Init_File(void);
int ruby_is_fd_loadable(int fd);
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;
}