Torrent example: Fix use-after-free crash
The crash would sometimes happen shortly after removing a torrent since the RateController would still try to use it even though it had been deallocated. Pick-to: 6.5 Task-number: QTBUG-110622 Change-Id: Icad1531ea58560a3a3157a3ed8c0e6b283573196 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io>
This commit is contained in:
parent
f3de92cdad
commit
32098963f2
@ -208,6 +208,10 @@ TorrentClient::TorrentClient(QObject *parent)
|
|||||||
|
|
||||||
TorrentClient::~TorrentClient()
|
TorrentClient::~TorrentClient()
|
||||||
{
|
{
|
||||||
|
auto rateController = RateController::instance();
|
||||||
|
const auto childSockets = findChildren<PeerWireClient *>(Qt::FindDirectChildrenOnly);
|
||||||
|
for (PeerWireClient *socket : childSockets)
|
||||||
|
rateController->removeSocket(socket);
|
||||||
qDeleteAll(d->peers);
|
qDeleteAll(d->peers);
|
||||||
qDeleteAll(d->pendingPieces);
|
qDeleteAll(d->pendingPieces);
|
||||||
delete d;
|
delete d;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user