From 4fe8cc61642c462883e748b566f93f984e3b4f2a Mon Sep 17 00:00:00 2001 From: Juan Lang Date: Thu, 9 Jun 2011 11:35:11 -0700 Subject: [PATCH] setupapi: Make sure machine name is non-empty before failing. --- dlls/setupapi/devinst.c | 6 +++--- dlls/setupapi/tests/devinst.c | 9 +++++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/dlls/setupapi/devinst.c b/dlls/setupapi/devinst.c index 0a3c3bd7fcc..91765549fe4 100644 --- a/dlls/setupapi/devinst.c +++ b/dlls/setupapi/devinst.c @@ -1163,7 +1163,7 @@ SetupDiCreateDeviceInfoListExW(const GUID *ClassGuid, TRACE("%s %p %s %p\n", debugstr_guid(ClassGuid), hwndParent, debugstr_w(MachineName), Reserved); - if (MachineName != NULL) + if (MachineName && *MachineName) { FIXME("remote support is not implemented\n"); SetLastError(ERROR_INVALID_MACHINENAME); @@ -2371,7 +2371,7 @@ HDEVINFO WINAPI SetupDiGetClassDevsExW( set = SetupDiCreateDeviceInfoListExW(class, parent, machine, reserved); if (set) { - if (machine) + if (machine && *machine) FIXME("%s: unimplemented for remote machines\n", debugstr_w(machine)); else if (flags & DIGCF_DEVICEINTERFACE) @@ -3562,7 +3562,7 @@ HKEY WINAPI SetupDiOpenClassRegKeyExW( LPCWSTR lpKeyName; LONG l; - if (MachineName != NULL) + if (MachineName && *MachineName) { FIXME("Remote access not supported yet!\n"); return INVALID_HANDLE_VALUE; diff --git a/dlls/setupapi/tests/devinst.c b/dlls/setupapi/tests/devinst.c index 190540612c7..3c01f320938 100644 --- a/dlls/setupapi/tests/devinst.c +++ b/dlls/setupapi/tests/devinst.c @@ -261,6 +261,7 @@ static void test_SetupDiCreateDeviceInfoListEx(void) DWORD error; static CHAR notnull[] = "NotNull"; static const WCHAR machine[] = { 'd','u','m','m','y',0 }; + static const WCHAR empty[] = { 0 }; SetLastError(0xdeadbeef); /* create empty DeviceInfoList, but set Reserved to a value, which is not NULL */ @@ -290,6 +291,14 @@ static void test_SetupDiCreateDeviceInfoListEx(void) /* destroy DeviceInfoList */ ret = pSetupDiDestroyDeviceInfoList(devlist); ok(ret, "SetupDiDestroyDeviceInfoList failed : %d\n", error); + + /* create empty DeviceInfoList with empty machine name */ + devlist = pSetupDiCreateDeviceInfoListExW(NULL, NULL, empty, NULL); + ok(devlist && devlist != INVALID_HANDLE_VALUE, "SetupDiCreateDeviceInfoListExW failed : %p %d (expected != %p)\n", devlist, error, INVALID_HANDLE_VALUE); + + /* destroy DeviceInfoList */ + ret = pSetupDiDestroyDeviceInfoList(devlist); + ok(ret, "SetupDiDestroyDeviceInfoList failed : %d\n", error); } static void test_SetupDiOpenClassRegKeyExA(void)