fixes crash on servers with invalid packet (#5289)

This commit is contained in:
Alexandru Ionut Tripon 2026-04-01 10:24:39 +00:00 committed by GitHub
commit a4c9e294da
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -60,9 +60,13 @@ void McClient::readRawResponse()
if (m_responseReadState == 1 && m_resp.size() >= m_wantedRespLength) { if (m_responseReadState == 1 && m_resp.size() >= m_wantedRespLength) {
if (m_resp.size() > m_wantedRespLength) { if (m_resp.size() > m_wantedRespLength) {
qDebug().nospace() << "Warning: Packet length doesn't match actual packet size (" << m_wantedRespLength << " expected vs " qDebug().nospace() << "Warning: Packet length doesn't match actual packet size (" << m_wantedRespLength << " expected vs "
<< m_resp.size() << " received)"; << m_resp.size() << " received)";
}
try {
parseResponse();
} catch (const Exception& e) {
emitFail(e.cause());
} }
parseResponse();
m_responseReadState = 2; m_responseReadState = 2;
} }
} }