Skip to content

Commit 5643a3b

Browse files
committed
Check readable before each iteration
1 parent 1bfee02 commit 5643a3b

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,8 @@ public IRubyObject each_byte(ThreadContext context, Block block) {
423423
// Check the length every iteration, since
424424
// the block can modify this string.
425425
while (ptr.pos < bytes.length()) {
426+
checkReadable();
427+
426428
block.yield(context, runtime.newFixnum(bytes.get(ptr.pos++) & 0xFF));
427429
}
428430
}
@@ -1280,6 +1282,8 @@ public IRubyObject each_codepoint(ThreadContext context, Block block) {
12801282
for (; ; ) {
12811283
if (ptr.pos >= ptr.string.size()) return this;
12821284

1285+
checkReadable();
1286+
12831287
int c = StringSupport.codePoint(runtime, enc, stringBytes, begin + ptr.pos, stringBytes.length);
12841288
int n = StringSupport.codeLength(enc, c);
12851289
block.yield(context, runtime.newFixnum(c));

0 commit comments

Comments
 (0)