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:
@@ -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)
|
||||||
|
Reference in New Issue
Block a user