summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--parse.y2
-rw-r--r--test/ripper/test_ripper.rb4
3 files changed, 10 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index a9e6b74..d7bd7b6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Mon Mar 24 22:19:56 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * parse.y (ripper_initialize): filename can not be modified.
+
Mon Mar 24 15:19:47 2014 NARUSE, Yui <naruse@ruby-lang.org>
* addr2line.c (rb_dump_backtrace_with_lines): fetch path of the
diff --git a/parse.y b/parse.y
index 492fd3d..8d3df90 100644
--- a/parse.y
+++ b/parse.y
@@ -11445,9 +11445,11 @@ ripper_initialize(int argc, VALUE *argv, VALUE self)
parser->eofp = Qfalse;
if (NIL_P(fname)) {
fname = STR_NEW2("(ripper)");
+ OBJ_FREEZE(fname);
}
else {
StringValue(fname);
+ fname = rb_str_new_frozen(fname);
}
parser_initialize(parser);
diff --git a/test/ripper/test_ripper.rb b/test/ripper/test_ripper.rb
index 1d6e893..b582de5 100644
--- a/test/ripper/test_ripper.rb
+++ b/test/ripper/test_ripper.rb
@@ -26,6 +26,10 @@ class TestRipper::Ripper < Test::Unit::TestCase
def test_filename
assert_equal '(ripper)', @ripper.filename
+ filename = "ripper"
+ ripper = Ripper.new("", filename)
+ filename.clear
+ assert_equal "ripper", ripper.filename
end
def test_lineno