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 <oliver.wolff@qt.io>
This commit is contained in:
Mårten Nordheim 2019-05-07 17:42:16 +02:00
parent a1516c3b93
commit 8adcfa8b24

View File

@ -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<QNativeSocketEngine> alive(this);
processReadReady();
if (alive.isNull())
return;
}
d->closingDown = true;