From b283ce1e836ab08e602a11ea255ee3d8e537902e Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Thu, 10 Dec 2020 11:11:23 +0100 Subject: [PATCH] secureudpclient - a speculative fix for non-reproducible crash MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Not much information in a bug report: QByteArray is protected from negative sizes and QUdpSocket too. FWIW - add one more check, similar to what the server counterpart already had. Pick-to: 5.15 6.0 Fixes: QTBUG-83457 Change-Id: I585fa90e0a258d2257e4fed2f24c52b47548bcbb Reviewed-by: MÃ¥rten Nordheim --- examples/network/secureudpclient/association.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/examples/network/secureudpclient/association.cpp b/examples/network/secureudpclient/association.cpp index c9502600789..59df94d5b91 100644 --- a/examples/network/secureudpclient/association.cpp +++ b/examples/network/secureudpclient/association.cpp @@ -112,6 +112,11 @@ void DtlsAssociation::udpSocketConnected() void DtlsAssociation::readyRead() { + if (socket.pendingDatagramSize() <= 0) { + emit warningMessage(tr("%1: spurious read notification?").arg(name)); + return; + } + //! [6] QByteArray dgram(socket.pendingDatagramSize(), Qt::Uninitialized); const qint64 bytesRead = socket.readDatagram(dgram.data(), dgram.size());