Fix the crash of test case authentication required

Empty transfer is caused by using its password,
resulting in a crash

Pick-to: 6.5
Change-Id: I2b208ce48b5abc2adea3278d875f3005cda77a8b
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
(cherry picked from commit 8143e85bb4706799f9275c25b2caf72b22b457a4)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Wang Yu 2024-08-16 10:20:40 +08:00 committed by Qt Cherry-pick Bot
parent 1079d210d1
commit 04f3381f11

View File

@ -82,7 +82,7 @@ void DownloadManager::authenticationRequired(QNetworkReply *reply, QAuthenticato
qDebug() << "authenticationRequired" << reply;
TransferItem *transfer = findTransfer(reply);
//provide the credentials exactly once, so that it fails if credentials are incorrect.
if ((transfer && !transfer->user.isEmpty()) || !transfer->password.isEmpty()) {
if (transfer && (!transfer->user.isEmpty() || !transfer->password.isEmpty())) {
auth->setUser(transfer->user);
auth->setPassword(transfer->password);
transfer->user.clear();