Browse Source

wsspectrum : Guard disconnected client logging

Only log the disconnected client after confirming the socket pointer is
valid. This avoids passing a null pointer to getWebSocketIdentifier() when
socketDisconnected() is invoked without a valid client sender.

Found by cppcheck.

Signed-off-by: Robin Getz <rgetz503@gmail.com>
chirpmodem-v8.0.0
Robin Getz 2 months ago
parent
commit
bbd62c366e
No known key found for this signature in database
GPG Key ID: 51C7231FFED0E060
  1. 2
      sdrbase/websockets/wsspectrum.cpp

2
sdrbase/websockets/wsspectrum.cpp

@ -126,10 +126,10 @@ void WSSpectrum::processClientMessage(const QString &message) @@ -126,10 +126,10 @@ void WSSpectrum::processClientMessage(const QString &message)
void WSSpectrum::socketDisconnected()
{
QWebSocket *pClient = qobject_cast<QWebSocket *>(sender());
qDebug() << getWebSocketIdentifier(pClient) << " disconnected";
if (pClient)
{
qDebug() << getWebSocketIdentifier(pClient) << " disconnected";
m_clients.removeAll(pClient);
pClient->deleteLater();
}

Loading…
Cancel
Save