Skip to content

Commit

Permalink
Modify string even if it didn't expand
Browse files Browse the repository at this point in the history
String data might be shared, so modify to ensure we have a writable
version.
  • Loading branch information
headius committed Feb 20, 2025
1 parent 3c2ba51 commit 0e84588
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions ext/java/org/jruby/ext/stringio/StringIO.java
Original file line number Diff line number Diff line change
Expand Up @@ -1559,6 +1559,7 @@ private void ungetbyteCommon(ThreadContext context, byte[] ungetBytes, int cp, i
strBytelist = str.getByteList();
strBytelist.setRealSize(len + rest);
} else {
str.modify();
strBytelist = str.getByteList();
}
strBytes = strBytelist.unsafeBytes();
Expand Down

0 comments on commit 0e84588

Please sign in to comment.