summaryrefslogtreecommitdiffstats
path: root/eval.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-10-23 15:41:17 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-10-23 15:41:17 +0000
commite0c3483dc667496098dd65d6ce0d1d260f3b8a13 (patch)
tree16754d090b3d6bd9d7be4142b4f164b1a3d69500 /eval.c
parenteb8b3a1fe48b8e75b1eb2c466cd286e5d1009385 (diff)
downloadruby-e0c3483dc667496098dd65d6ce0d1d260f3b8a13.tar.gz
ruby-e0c3483dc667496098dd65d6ce0d1d260f3b8a13.tar.xz
ruby-e0c3483dc667496098dd65d6ce0d1d260f3b8a13.zip
* eval.c (rb_load, search_required, rb_require_safe, rb_require): use
frozen shared string to avoid outside modification. [ruby-dev:24580] git-svn-id: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_8@7106 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'eval.c')
-rw-r--r--eval.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/eval.c b/eval.c
index 7df2799ca..392bd50ea 100644
--- a/eval.c
+++ b/eval.c
@@ -6444,6 +6444,7 @@ rb_load(fname, wrap)
else {
SafeStringValue(fname);
}
+ fname = rb_str_new4(fname);
tmp = rb_find_file(fname);
if (!tmp) {
load_failed(fname);
@@ -6696,7 +6697,7 @@ search_required(fname, featurep, path)
char *ext, *ftptr;
int type;
- *featurep = fname = rb_str_new4(fname);
+ *featurep = fname;
*path = 0;
ext = strrchr(ftptr = RSTRING(fname)->ptr, '.');
if (ext && !strchr(ext, '/')) {
@@ -6710,6 +6711,7 @@ search_required(fname, featurep, path)
tmp = rb_str_new(RSTRING(fname)->ptr, ext-RSTRING(fname)->ptr);
*featurep = tmp;
#ifdef DLEXT2
+ OBJ_FREEZE(tmp);
if (rb_find_file_ext(&tmp, loadable_ext+1)) {
*featurep = tmp;
*path = rb_find_file(tmp);
@@ -6717,6 +6719,7 @@ search_required(fname, featurep, path)
}
#else
rb_str_cat2(tmp, DLEXT);
+ OBJ_FREEZE(tmp);
if (*path = rb_find_file(tmp)) {
return 's';
}
@@ -6771,6 +6774,7 @@ rb_require_safe(fname, safe)
rb_check_safe_obj(fname);
}
StringValue(fname);
+ fname = rb_str_new4(fname);
saved.vmode = scope_vmode;
saved.node = ruby_current_node;
saved.func = ruby_frame->last_func;
@@ -6841,7 +6845,9 @@ VALUE
rb_require(fname)
const char *fname;
{
- return rb_require_safe(rb_str_new2(fname), ruby_safe_level);
+ VALUE fn = rb_str_new2(fname);
+ OBJ_FREEZE(fn);
+ return rb_require_safe(fn, ruby_safe_level);
}
static void