remove infinite loop from readVarInt()

This commit is contained in:
iTrooz 2024-11-28 17:32:49 +01:00
parent 873232ebe3
commit 8b90a9f2b3
No known key found for this signature in database
GPG Key ID: 8B83F77667B1BC6A

View File

@ -117,17 +117,17 @@ int McClient::readVarInt(QByteArray &data) {
int position = 0;
char currentByte;
while (true) {
while (position < 32) {
currentByte = readByte(data);
value |= (currentByte & SEGMENT_BITS) << position;
if ((currentByte & CONTINUE_BIT) == 0) break;
position += 7;
if (position >= 32) throw Exception("VarInt is too big");
}
if (position >= 32) throw Exception("VarInt is too big");
return value;
}