From 6cf3b65953021454678c91d6a9ab8369c61c3ebd Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Wed, 1 Mar 2023 18:00:59 -0800 Subject: [PATCH] Fix #1883 (#1886) Still unknown as to why, but the call to `nc->GetProperties()` can fail when setting a friendly name on the Windows virtual ethernet adapter. Ensure that `ncp` is not null before continuing and accessing the device GUID. --- osdep/WindowsEthernetTap.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/osdep/WindowsEthernetTap.cpp b/osdep/WindowsEthernetTap.cpp index c0dcbd98f..db65bbf41 100644 --- a/osdep/WindowsEthernetTap.cpp +++ b/osdep/WindowsEthernetTap.cpp @@ -850,12 +850,14 @@ void WindowsEthernetTap::setFriendlyName(const char *dn) NETCON_PROPERTIES *ncp = nullptr; nc->GetProperties(&ncp); - GUID curId = ncp->guidId; - if (curId == _deviceGuid) { - wchar_t wtext[255]; - mbstowcs(wtext, dn, strlen(dn)+1); - nc->Rename(wtext); - found = true; + if (ncp != nullptr) { + GUID curId = ncp->guidId; + if (curId == _deviceGuid) { + wchar_t wtext[255]; + mbstowcs(wtext, dn, strlen(dn)+1); + nc->Rename(wtext); + found = true; + } } nc->Release(); }