Use QscopedValueRollback in startRequestSynchronously()

Use QscopedValueRollback in
QHttpThreadDelegate::startRequestSynchronously
to handle a "Potentially leaking reference/pointer to local variable"
warning.

Found by an Axivion scan.

Task-number: QTBUG-125026
Pick-to: 6.7 6.5
Change-Id: I18c7b9e2f4f8093393176eedfb3ed5a2604bf51b
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
(cherry picked from commit 41f6338a7d8b848008d7906016bda498c13928e1)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Mate Barany 2024-07-19 13:05:41 +02:00 committed by Qt Cherry-pick Bot
parent 191969e432
commit 4ed494f4ad

View File

@ -9,6 +9,7 @@
#include <QAuthenticator>
#include <QEventLoop>
#include <QCryptographicHash>
#include <QtCore/qscopedvaluerollback.h>
#include "private/qhttpnetworkreply_p.h"
#include "private/qnetworkaccesscache_p.h"
@ -215,7 +216,7 @@ void QHttpThreadDelegate::startRequestSynchronously()
synchronous = true;
QEventLoop synchronousRequestLoop;
this->synchronousRequestLoop = &synchronousRequestLoop;
QScopedValueRollback<QEventLoop*> guard(this->synchronousRequestLoop, &synchronousRequestLoop);
// Worst case timeout
QTimer::singleShot(30*1000, this, SLOT(abortRequest()));