Skip to content

Commit

Permalink
Ensure that reading more characters at the end of the buffer is not s…
Browse files Browse the repository at this point in the history
…topped due to the buffer appearing being at the end with reading, rather we read till we get a -1. Streams can deliver less than requested size and hence the buffer looks like it it almost finished, but it is technically not.
  • Loading branch information
rschwietzke authored and rbri committed Mar 14, 2024
1 parent b40fa65 commit 1053426
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/main/java/org/htmlunit/cyberneko/HTMLScanner.java
Original file line number Diff line number Diff line change
Expand Up @@ -2341,10 +2341,8 @@ protected String nextContent(final int len) throws IOException {
for (nbRead = 0; nbRead < len; ++nbRead) {
// read() should not clear the buffer
if (fCurrentEntity.offset_ == fCurrentEntity.length_) {
if (fCurrentEntity.length_ == fCurrentEntity.buffer_.length) {
fCurrentEntity.load(fCurrentEntity.buffer_.length);
}
else { // everything was already loaded
final int count = fCurrentEntity.load(fCurrentEntity.offset_);
if (count == -1) {
break;
}
}
Expand Down

0 comments on commit 1053426

Please sign in to comment.