Skip to content

Commit 29b9133

Browse files
committed
Fix SEGV at eof? on null StringIO
1 parent 113dd5a commit 29b9133

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -650,7 +650,7 @@ public IRubyObject each_char(final ThreadContext context, final Block block) {
650650
public IRubyObject eof(ThreadContext context) {
651651
checkReadable();
652652
StringIOData ptr = getPtr();
653-
if (ptr.pos < ptr.string.size()) return context.fals;
653+
if (!isEndOfString()) return context.fals;
654654
return context.tru;
655655
}
656656

test/stringio/test_stringio.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@ def test_null
7070
assert_nil io.getc
7171
end
7272

73+
def test_pread_eof
74+
io = StringIO.new(nil)
75+
assert_predicate io, :eof?
76+
end
77+
7378
def test_pread_null
7479
io = StringIO.new(nil)
7580
assert_raise(EOFError) { io.pread(1, 0) }

0 commit comments

Comments
 (0)