Skip to content

Commit 8afacbd

Browse files
committed
Fix null StringIO modifiable check
See eb4ee49
1 parent 935e745 commit 8afacbd

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

ext/java/org/jruby/ext/stringio/StringIO.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2201,8 +2201,13 @@ private void checkWritable() {
22012201
}
22022202

22032203
private void checkModifiable() {
2204-
checkFrozen();
2205-
if (getPtr().string.isFrozen()) throw getRuntime().newIOError("not modifiable string");
2204+
if (getPtr().string == null || getPtr().string.isNil()) {
2205+
/* Null device StringIO */
2206+
} else if (getPtr().string.isFrozen()) {
2207+
throw getRuntime().newIOError("not modifiable string");
2208+
} else {
2209+
getPtr().string.modify();
2210+
}
22062211
}
22072212

22082213
private void checkInitialized() {

0 commit comments

Comments
 (0)