QNetworkConnectionEvents: fix potential nullptr access

Fix potential nullptr access in
QNetworkConnectionEvents::getNetworkConnectionFromAdapterGuid().
This can happen if for some reason the NetworkListManager instance
failed to be instantiated in QNetworkConnectionEvents constructor.

Fixes: QTBUG-117097
Pick-to: 6.5
Change-Id: If51ea383e22461a6c3124576c4e1be3f30dde1f6
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
(cherry picked from commit 6b4cc9bf7358176890630879dbdd08f6d4535bd9)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Vladimir Belyavsky 2023-09-15 18:00:11 +03:00 committed by Qt Cherry-pick Bot
parent 6c9ecf98e1
commit a7e0d6ebdc

View File

@ -167,6 +167,12 @@ QNetworkConnectionEvents::~QNetworkConnectionEvents()
ComPtr<INetworkConnection> QNetworkConnectionEvents::getNetworkConnectionFromAdapterGuid(QUuid guid)
{
if (!networkListManager) {
qCDebug(lcNetMon) << "Failed to enumerate network connections:"
<< "NetworkListManager was not instantiated";
return nullptr;
}
ComPtr<IEnumNetworkConnections> connections;
auto hr = networkListManager->GetNetworkConnections(connections.GetAddressOf());
if (FAILED(hr)) {