summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAleksey Lysenko <lysenkoalexmail@gmail.com>2017-01-03 22:59:36 +0200
committerAleksey Lysenko <lysenkoalexmail@gmail.com>2017-01-04 13:08:28 +0000
commit2eeee81b67ce4fc81793c51bafd2cc1b33076c05 (patch)
tree00322a9d3afa9bb77322124c89927598a0cb1e42 /src
parent9ae40f96a47259315e06ba9dfa253ecd95c790f1 (diff)
downloadqtwebsockets-2eeee81b67ce4fc81793c51bafd2cc1b33076c05.tar.gz
Fixed possible block clearing in QWebSocketDataProcessor::process method
In QWebSocketDataProcessor::process() the signals text(binary)MessageReceived are emitted before clear() method. If signal handler blocks loop (for example, using QDialog::exec()), clear() will be called only after resuming loop. It may lead to the data corruption due to the fact that QWebSocketDataProcessor clearing won't be performed before the new data arrived. Task-number: QTBUG-55506 Change-Id: Ib7016a91d3987dec7c1af977b17f86a53568c413 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/websockets/qwebsocketdataprocessor.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/websockets/qwebsocketdataprocessor.cpp b/src/websockets/qwebsocketdataprocessor.cpp
index 520ecdc..d9fc550 100644
--- a/src/websockets/qwebsocketdataprocessor.cpp
+++ b/src/websockets/qwebsocketdataprocessor.cpp
@@ -182,12 +182,16 @@ void QWebSocketDataProcessor::process(QIODevice *pIoDevice)
}
if (frame.isFinalFrame()) {
- if (m_opCode == QWebSocketProtocol::OpCodeText)
- Q_EMIT textMessageReceived(m_textMessage);
- else
- Q_EMIT binaryMessageReceived(m_binaryMessage);
- clear();
isDone = true;
+ if (m_opCode == QWebSocketProtocol::OpCodeText) {
+ const QString textMessage(m_textMessage);
+ clear();
+ Q_EMIT textMessageReceived(textMessage);
+ } else {
+ const QByteArray binaryMessage(m_binaryMessage);
+ clear();
+ Q_EMIT binaryMessageReceived(binaryMessage);
+ }
}
}
} else {