diff --git a/src/websockets/qwebsocketdataprocessor.cpp b/src/websockets/qwebsocketdataprocessor.cpp
index 80706980c5f01a46136867d506be81eecfa12ad5..4f812229ab863d60af2d8da319171da54e46935f 100644
--- a/src/websockets/qwebsocketdataprocessor.cpp
+++ b/src/websockets/qwebsocketdataprocessor.cpp
@@ -150,9 +150,9 @@ void QWebSocketDataProcessor::process(QIODevice *pIoDevice)
                     m_opCode = frame.opCode();
                     m_isFragmented = !frame.isFinalFrame();
                 }
-                quint64 messageLength = (quint64)(m_opCode == QWebSocketProtocol::OpCodeText)
-                        ? m_textMessage.length()
-                        : m_binaryMessage.length();
+                quint64 messageLength = m_opCode == QWebSocketProtocol::OpCodeText
+                        ? quint64(m_textMessage.length())
+                        : quint64(m_binaryMessage.length());
                 if (Q_UNLIKELY((messageLength + quint64(frame.payload().length())) >
                                MAX_MESSAGE_SIZE_IN_BYTES)) {
                     clear();