fix string reading

This commit is contained in:
Bixilon 2020-12-05 16:10:26 +01:00
parent f359eb2d49
commit 005f3c0f01
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4

View File

@ -105,7 +105,7 @@ public class InByteBuffer {
if (data.length > ProtocolDefinition.STRING_MAX_LEN) {
throw new IllegalArgumentException(String.format("String max string length exceeded %d > %d", data.length, ProtocolDefinition.STRING_MAX_LEN));
}
return new String(readBytes(readVarInt()), StandardCharsets.UTF_8);
return new String(data, StandardCharsets.UTF_8);
}
public long readVarLong() {
@ -114,7 +114,7 @@ public class InByteBuffer {
byte read;
do {
read = readByte();
result |= (read & 0x7F) << (7 * byteCount);
result |= (long) (read & 0x7F) << (7 * byteCount);
byteCount++;
if (byteCount > 10) {
throw new IllegalArgumentException("VarLong is too big");