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.
pull/835/head
Nicolas Werner 3 years ago
parent ff502f306c
commit 07e187d4d8
No known key found for this signature in database
GPG Key ID: C8D75E610773F2D9
  1. 4
      third_party/SingleApplication-3.3.0/singleapplication_p.cpp

@ -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 )

Loading…
Cancel
Save