Skip to content

Commit ac0ad23

Browse files
committed
fix: prevent NullPointerException in StringIO#seek with SEEK_END on null device (JRuby)
1 parent 7a953f4 commit ac0ad23

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1378,7 +1378,11 @@ private RubyFixnum seekCommon(ThreadContext context, int argc, IRubyObject arg0,
13781378
offset += ptr.pos;
13791379
break;
13801380
case 2:
1381-
offset += ptr.string.size();
1381+
if (ptr.string == null) {
1382+
offset += 0;
1383+
} else {
1384+
offset += ptr.string.size();
1385+
}
13821386
break;
13831387
default:
13841388
throw runtime.newErrnoEINVALError("invalid whence");

0 commit comments

Comments
 (0)