diff options
author | Frederik Gladhorn <frederik.gladhorn@digia.com> | 2014-01-17 11:04:41 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-01-17 13:47:08 +0100 |
commit | 0e9731659f5a9d865889dd766959b7eeae16e5a5 (patch) | |
tree | 4d3a8df7a587d3fa84a738694766cb453e245b55 /src/websockets | |
parent | ea7c77e87f317cd72278ba4f9955b74b9cdfeedf (diff) | |
download | qtwebsockets-0e9731659f5a9d865889dd766959b7eeae16e5a5.tar.gz |
Make sure that the random generator is initialized in all code paths
Change-Id: Ice4826e7670cffa791250a95387ac1121ddc4089
Reviewed-by: Kurt Pattyn <pattyn.kurt@gmail.com>
Diffstat (limited to 'src/websockets')
-rw-r--r-- | src/websockets/qwebsocket_p.cpp | 14 | ||||
-rw-r--r-- | src/websockets/qwebsocket_p.h | 1 |
2 files changed, 12 insertions, 3 deletions
diff --git a/src/websockets/qwebsocket_p.cpp b/src/websockets/qwebsocket_p.cpp index 2b63860..7d6c7a9 100644 --- a/src/websockets/qwebsocket_p.cpp +++ b/src/websockets/qwebsocket_p.cpp @@ -109,8 +109,7 @@ QWebSocketPrivate::QWebSocketPrivate(const QString &origin, QWebSocketProtocol:: m_dataProcessor(), m_configuration() { - Q_ASSERT(pWebSocket); - qsrand(static_cast<uint>(QDateTime::currentMSecsSinceEpoch())); + init(); } /*! @@ -139,13 +138,22 @@ QWebSocketPrivate::QWebSocketPrivate(QTcpSocket *pTcpSocket, QWebSocketProtocol: m_dataProcessor(), m_configuration() { - Q_ASSERT(pWebSocket); + init(); makeConnections(m_pSocket.data()); } /*! \internal */ +void QWebSocketPrivate::init() +{ + Q_ASSERT(q_ptr); + qsrand(static_cast<uint>(QDateTime::currentMSecsSinceEpoch())); +} + +/*! + \internal +*/ QWebSocketPrivate::~QWebSocketPrivate() { if (!m_pSocket) diff --git a/src/websockets/qwebsocket_p.h b/src/websockets/qwebsocket_p.h index 68317ea..2786727 100644 --- a/src/websockets/qwebsocket_p.h +++ b/src/websockets/qwebsocket_p.h @@ -107,6 +107,7 @@ public: QObject *parent = Q_NULLPTR); virtual ~QWebSocketPrivate(); + void init(); void abort(); QAbstractSocket::SocketError error() const; QString errorString() const; |