Fix crash when sending ack on removed connection

The emit might interrupt our function and causes us to return to the
event loop. In that time frame the other and might close the connection,
causing our connection to be removed. In that case we call writeAck on a
dangling pointer, in the best case causing a crash. So lets finish our
business before emitting our signal.

fixes #138
This commit is contained in:
Nicolas Werner 2021-11-24 05:30:41 +01:00
parent 0d7b2630bd
commit 3650975e56
No known key found for this signature in database
GPG Key ID: C8D75E610773F2D9

View File

@ -503,12 +503,14 @@ void SingleApplicationPrivate::slotDataAvailable( QLocalSocket *dataSocket, quin
if ( !isFrameComplete( dataSocket ) )
return;
Q_EMIT q->receivedMessage( instanceId, dataSocket->readAll() );
const QByteArray message = dataSocket->readAll();
writeAck( dataSocket );
ConnectionInfo &info = connectionMap[dataSocket];
info.stage = StageConnectedHeader;
Q_EMIT q->receivedMessage( instanceId, message);
}
void SingleApplicationPrivate::slotClientConnectionClosed( QLocalSocket *closedSocket, quint32 instanceId )