summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMilian Wolff <mail@milianw.de>2014-02-06 17:48:28 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-02-06 20:17:30 +0100
commitdaf0faa0930b72a78ff940ecbf2a5eb8930fd793 (patch)
tree466f41353d4aa9c99c4303702673bd3cffe51b49
parent862ac1547c19b02fc36bdc4b6ce5c6cf3442a868 (diff)
downloadqtwebsockets-daf0faa0930b72a78ff940ecbf2a5eb8930fd793.tar.gz
Do not double-delete the TCP socket of a QWebSocket.
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>
-rw-r--r--src/websockets/qwebsocket_p.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/websockets/qwebsocket_p.cpp b/src/websockets/qwebsocket_p.cpp
index 5f59b54..d05b321 100644
--- a/src/websockets/qwebsocket_p.cpp
+++ b/src/websockets/qwebsocket_p.cpp
@@ -366,7 +366,7 @@ void QWebSocketPrivate::open(const QUrl &url, bool mask)
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);
@@ -397,7 +397,7 @@ void QWebSocketPrivate::open(const QUrl &url, bool mask)
} 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);