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.6 6.5
Change-Id: If51ea383e22461a6c3124576c4e1be3f30dde1f6
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
bb10
Vladimir Belyavsky 2023-09-15 18:00:11 +03:00
parent 1e25bf5f4d
commit 6b4cc9bf73
1 changed files with 6 additions and 0 deletions

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)) {