The socket is put into an owning QScopedPointer. But if its also
put into the QObject parent-child chain, it will get deleted when
the QWebSocket is destroyed. In the dtor of the QWebSocketPrivate
class m_pSocket will thus already be destroyed and thus be a
dangling pointer.
This crashed the QWebSocketServer test reliably for me on exit.
Change-Id: I7f06e933bfed832e66b943542c351cde639c9465
Reviewed-by: Kurt Pattyn <pattyn.kurt@gmail.com>
setErrorString(message);
Q_EMIT q->error(QAbstractSocket::UnsupportedSocketOperationError);
} else {
setErrorString(message);
Q_EMIT q->error(QAbstractSocket::UnsupportedSocketOperationError);
} else {
- QSslSocket *sslSocket = new QSslSocket(q);
+ QSslSocket *sslSocket = new QSslSocket;
m_pSocket.reset(sslSocket);
if (Q_LIKELY(m_pSocket)) {
m_pSocket->setSocketOption(QAbstractSocket::LowDelayOption, 1);
m_pSocket.reset(sslSocket);
if (Q_LIKELY(m_pSocket)) {
m_pSocket->setSocketOption(QAbstractSocket::LowDelayOption, 1);
} else
#endif
if (url.scheme() == QStringLiteral("ws")) {
} else
#endif
if (url.scheme() == QStringLiteral("ws")) {
- m_pSocket.reset(new QTcpSocket(q));
+ m_pSocket.reset(new QTcpSocket);
if (Q_LIKELY(m_pSocket)) {
m_pSocket->setSocketOption(QAbstractSocket::LowDelayOption, 1);
m_pSocket->setSocketOption(QAbstractSocket::KeepAliveOption, 1);
if (Q_LIKELY(m_pSocket)) {
m_pSocket->setSocketOption(QAbstractSocket::LowDelayOption, 1);
m_pSocket->setSocketOption(QAbstractSocket::KeepAliveOption, 1);