1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-08-15 20:03:15 +02:00

Throw exception instead of failing with SIGSEGV

This commit is contained in:
Ivan Savenko
2023-12-17 19:32:05 +02:00
parent dd88220b7c
commit 84d9078bd9

View File

@@ -148,6 +148,9 @@ void CConnection::flushBuffers()
if(!enableBufferedWrite) if(!enableBufferedWrite)
return; return;
if (!socket)
throw std::runtime_error("Can't write to closed socket!");
try try
{ {
asio::write(*socket, connectionBuffers->writeBuffer); asio::write(*socket, connectionBuffers->writeBuffer);
@@ -164,6 +167,9 @@ void CConnection::flushBuffers()
int CConnection::write(const void * data, unsigned size) int CConnection::write(const void * data, unsigned size)
{ {
if (!socket)
throw std::runtime_error("Can't write to closed socket!");
try try
{ {
if(enableBufferedWrite) if(enableBufferedWrite)