From 8adcfa8b240876236f08ad826e6d77ff1f5e9a96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Tue, 7 May 2019 17:42:16 +0200 Subject: WinRT: Fix crash in native socket engine during close Make sure "this" still exists when we're done sending the readNotification. The crash manifested itself when connecting to certain websites as they would reply with status 403, then close the connection. On our end we would then handle this "remote host closed" followed by handling the data we received. The http code handles the data successfully and sees we are done and there is nothing more to do, so it closes the connection. Which leads to closing QAbstractSocket, which closes native socket again and then deletes it. Fixes: QTBUG-75620 Change-Id: I233c67f359aa8234f1a2c4ea9463108b08c9165f Reviewed-by: Oliver Wolff --- src/network/socket/qnativesocketengine_winrt.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/network') diff --git a/src/network/socket/qnativesocketengine_winrt.cpp b/src/network/socket/qnativesocketengine_winrt.cpp index 7ac6297de6..2eb2141fee 100644 --- a/src/network/socket/qnativesocketengine_winrt.cpp +++ b/src/network/socket/qnativesocketengine_winrt.cpp @@ -875,8 +875,14 @@ void QNativeSocketEngine::close() if (d->closingDown) return; - if (d->pendingReadNotification) + if (d->pendingReadNotification) { + // We use QPointer here to see if this QNativeSocketEngine was deleted as a result of + // finishing and cleaning up a network request when calling "processReadReady". + QPointer alive(this); processReadReady(); + if (alive.isNull()) + return; + } d->closingDown = true; -- cgit v1.2.3