setupapi: Avoid unnecessary buffer allocation in SETUPDI_EnumerateMatchingDeviceInstances().
Signed-off-by: Zebediah Figura <z.figura12@gmail.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
462c74bcdb
commit
0c0aa90a90
|
@ -2083,6 +2083,7 @@ static void SETUPDI_EnumerateMatchingDeviceInstances(struct DeviceInfoSet *set,
|
||||||
LPCWSTR enumerator, LPCWSTR deviceName, HKEY deviceKey,
|
LPCWSTR enumerator, LPCWSTR deviceName, HKEY deviceKey,
|
||||||
const GUID *class, DWORD flags)
|
const GUID *class, DWORD flags)
|
||||||
{
|
{
|
||||||
|
WCHAR id[MAX_DEVICE_ID_LEN];
|
||||||
DWORD i, len;
|
DWORD i, len;
|
||||||
WCHAR deviceInstance[MAX_PATH];
|
WCHAR deviceInstance[MAX_PATH];
|
||||||
LONG l = ERROR_SUCCESS;
|
LONG l = ERROR_SUCCESS;
|
||||||
|
@ -2120,18 +2121,11 @@ static void SETUPDI_EnumerateMatchingDeviceInstances(struct DeviceInfoSet *set,
|
||||||
{
|
{
|
||||||
static const WCHAR fmt[] =
|
static const WCHAR fmt[] =
|
||||||
{'%','s','\\','%','s','\\','%','s',0};
|
{'%','s','\\','%','s','\\','%','s',0};
|
||||||
LPWSTR instanceId;
|
|
||||||
|
|
||||||
instanceId = HeapAlloc(GetProcessHeap(), 0,
|
if (snprintfW(id, ARRAY_SIZE(id), fmt, enumerator,
|
||||||
(lstrlenW(enumerator) + lstrlenW(deviceName) +
|
deviceName, deviceInstance) != -1)
|
||||||
lstrlenW(deviceInstance) + 3) * sizeof(WCHAR));
|
|
||||||
if (instanceId)
|
|
||||||
{
|
{
|
||||||
sprintfW(instanceId, fmt, enumerator,
|
SETUPDI_CreateDeviceInfo(set, &deviceClass, id, FALSE);
|
||||||
deviceName, deviceInstance);
|
|
||||||
SETUPDI_CreateDeviceInfo(set, &deviceClass,
|
|
||||||
instanceId, FALSE);
|
|
||||||
HeapFree(GetProcessHeap(), 0, instanceId);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue