mirror of
https://github.com/vcmi/vcmi.git
synced 2025-08-13 19:54:17 +02:00
Better checks for incoming data
This commit is contained in:
@@ -94,7 +94,13 @@ CPack * CConnection::retrievePack(const std::vector<std::byte> & data)
|
|||||||
|
|
||||||
*deserializer & result;
|
*deserializer & result;
|
||||||
|
|
||||||
logNetwork->trace("Received CPack of type %s", (result ? typeid(*result).name() : "nullptr"));
|
if (result == nullptr)
|
||||||
|
throw std::runtime_error("Failed to retrieve pack!");
|
||||||
|
|
||||||
|
if (packReader->position != data.size())
|
||||||
|
throw std::runtime_error("Failed to retrieve pack! Not all data has been read!");
|
||||||
|
|
||||||
|
logNetwork->trace("Received CPack of type %s", typeid(*result).name());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user