From 8b90a9f2b3e3d58b9725eda081cf209781c13aa6 Mon Sep 17 00:00:00 2001 From: iTrooz Date: Thu, 28 Nov 2024 17:32:49 +0100 Subject: [PATCH] remove infinite loop from readVarInt() --- launcher/ui/pages/instance/McClient.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/launcher/ui/pages/instance/McClient.cpp b/launcher/ui/pages/instance/McClient.cpp index f2cf1394f..f8a222645 100644 --- a/launcher/ui/pages/instance/McClient.cpp +++ b/launcher/ui/pages/instance/McClient.cpp @@ -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; }