Commit 5711f03e authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

setupapi: Correctly calculate the required size in SetupDiGetDeviceInterfaceDetailA().

Don't include the null terminator twice.
parent 60af599b
......@@ -3003,7 +3003,7 @@ BOOL WINAPI SetupDiGetDeviceInterfaceDetailA(HDEVINFO devinfo, SP_DEVICE_INTERFA
if (iface->symlink)
bytesNeeded += WideCharToMultiByte(CP_ACP, 0, iface->symlink, -1,
NULL, 0, NULL, NULL);
NULL, 0, NULL, NULL) - 1;
if (DeviceInterfaceDetailDataSize >= bytesNeeded)
{
if (iface->symlink)
......
......@@ -1232,7 +1232,7 @@ static void test_device_iface_detail(void)
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "Got unexpected error %#lx.\n", GetLastError());
expected_size = FIELD_OFFSET(SP_DEVICE_INTERFACE_DETAIL_DATA_A, DevicePath[strlen(path) + 1]);
todo_wine ok(size == expected_size, "Expected size %lu, got %lu.\n", expected_size, size);
ok(size == expected_size, "Expected size %lu, got %lu.\n", expected_size, size);
detail = heap_alloc(size * 2);
detail->cbSize = 0;
......@@ -1255,9 +1255,8 @@ static void test_device_iface_detail(void)
SetLastError(0xdeadbeef);
size = 0xdeadbeef;
ret = SetupDiGetDeviceInterfaceDetailA(set, &iface, detail, expected_size, &size, NULL);
todo_wine ok(ret, "Failed to get interface detail, error %#lx.\n", GetLastError());
if (ret)
ok(!strcasecmp(path, detail->DevicePath), "Got unexpected path %s.\n", detail->DevicePath);
ok(ret, "Failed to get interface detail, error %#lx.\n", GetLastError());
ok(!strcasecmp(path, detail->DevicePath), "Got unexpected path %s.\n", detail->DevicePath);
todo_wine ok(size == expected_size, "Expected size %lu, got %lu.\n", expected_size, size);
SetLastError(0xdeadbeef);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment