Fix crash in SingleApplication when other end exits immediately

In those cases the emit might cause the server to remove the connection
and we are working with a dangling pointer. We can't call putChar on
that, so acknowledge the message immediately and then emit the message.
This commit is contained in:
Nicolas Werner 2021-11-24 05:21:30 +01:00
parent ff502f306c
commit 07e187d4d8
No known key found for this signature in database
GPG key ID: C8D75E610773F2D9

View file

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