File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed
core/src/test/java/org/jruby/test Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -73,4 +73,20 @@ public void testSplit() throws RaiseException {
7373 res = str .split (context , pat , 4 );
7474 assertEquals (3 , res .size ());
7575 }
76+
77+ // See https://github.com/jruby/jruby/pull/9145
78+ public void testDefensiveFString () throws Throwable {
79+ byte [] bytes = ByteList .plain ("foo9145" );
80+ RubyString goodString = newString (context , bytes );
81+ RubyString badString = newString (context , bytes );
82+ ByteList badBytes = badString .getByteList ();
83+
84+ RubyString fstring = context .runtime .freezeAndDedupString (badString );
85+ badBytes .set (0 , 'b' );
86+
87+ // previously returned fstring should not have been modified
88+ assertEquals (goodString , fstring );
89+ assertNotSame (fstring .getByteList (), badBytes );
90+ assertNotSame (fstring .getByteList ().unsafeBytes (), badBytes .unsafeBytes ());
91+ }
7692}
You can’t perform that action at this time.
0 commit comments