Skip to content

Commit 8b43bc0

Browse files
committed
adjust to latest code
1 parent 36f207f commit 8b43bc0

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/main/java/org/htmlunit/util/brotli/BitReader.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,10 @@ static int readMoreInput(State s) {
7272
while (bytesInBuffer < CAPACITY) {
7373
final int spaceLeft = CAPACITY - bytesInBuffer;
7474
final int len = Utils.readInput(s, s.byteBuffer, bytesInBuffer, spaceLeft);
75-
// EOF is -1 in Java, but 0 in C#.
7675
if (len < BROTLI_ERROR) {
7776
return len;
7877
}
78+
// EOF is -1 in Java, but 0 in C#.
7979
if (len <= 0) {
8080
s.endOfStreamReached = 1;
8181
s.tailBytes = bytesInBuffer;
@@ -161,8 +161,9 @@ static int readFewBits(State s, int n) {
161161
static int readBits(State s, int n) {
162162
if (HALF_BITNESS >= 24) {
163163
return readFewBits(s, n);
164+
} else {
165+
return (n <= 16) ? readFewBits(s, n) : readManyBits(s, n);
164166
}
165-
return (n <= 16) ? readFewBits(s, n) : readManyBits(s, n);
166167
}
167168

168169
private static int readManyBits(State s, int n) {
@@ -274,10 +275,10 @@ static int copyRawBytes(State s, byte[] data, int offset, int length) {
274275
// Now it is possible to copy bytes directly.
275276
while (len > 0) {
276277
final int chunkLen = Utils.readInput(s, data, pos, len);
277-
// EOF is -1 in Java, but 0 in C#.
278-
if (len < BROTLI_ERROR) {
279-
return len;
278+
if (chunkLen < BROTLI_ERROR) {
279+
return chunkLen;
280280
}
281+
// EOF is -1 in Java, but 0 in C#.
281282
if (chunkLen <= 0) {
282283
return Utils.makeError(s, BROTLI_ERROR_TRUNCATED_INPUT);
283284
}

0 commit comments

Comments
 (0)