Fix readVarLong.

This commit is contained in:
Steven Smith 2016-08-13 17:12:34 -07:00
parent 885d03759d
commit 1b5b2c37a0
2 changed files with 6 additions and 6 deletions

View file

@ -77,17 +77,17 @@ public class ByteBufferNetInput implements NetInput {
@Override @Override
public long readVarLong() throws IOException { public long readVarLong() throws IOException {
int value = 0; long value = 0;
int size = 0; int size = 0;
int b; int b;
while(((b = this.readByte()) & 0x80) == 0x80) { while(((b = this.readByte()) & 0x80) == 0x80) {
value |= (b & 0x7F) << (size++ * 7); value |= (long) (b & 0x7F) << (size++ * 7);
if(size > 10) { if(size > 10) {
throw new IOException("VarLong too long (length must be <= 10)"); throw new IOException("VarLong too long (length must be <= 10)");
} }
} }
return value | ((b & 0x7F) << (size * 7)); return value | ((long) (b & 0x7F) << (size * 7));
} }
@Override @Override

View file

@ -93,17 +93,17 @@ public class StreamNetInput implements NetInput {
@Override @Override
public long readVarLong() throws IOException { public long readVarLong() throws IOException {
int value = 0; long value = 0;
int size = 0; int size = 0;
int b; int b;
while(((b = this.readByte()) & 0x80) == 0x80) { while(((b = this.readByte()) & 0x80) == 0x80) {
value |= (b & 0x7F) << (size++ * 7); value |= (long) (b & 0x7F) << (size++ * 7);
if(size > 10) { if(size > 10) {
throw new IOException("VarLong too long (length must be <= 10)"); throw new IOException("VarLong too long (length must be <= 10)");
} }
} }
return value | ((b & 0x7F) << (size * 7)); return value | ((long) (b & 0x7F) << (size * 7));
} }
@Override @Override