diff --git a/ChangeLog b/ChangeLog index a9e6b7404e..d7bd7b60f0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Mon Mar 24 22:19:56 2014 Nobuyoshi Nakada + + * parse.y (ripper_initialize): filename can not be modified. + Mon Mar 24 15:19:47 2014 NARUSE, Yui * addr2line.c (rb_dump_backtrace_with_lines): fetch path of the diff --git a/parse.y b/parse.y index 492fd3da64..8d3df90b0a 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 1d6e8934ef..b582de5163 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