Skip to content

Commit 15fdc6a

Browse files
authored
win32: Make sure to free device list at the right place
1 parent 2fff426 commit 15fdc6a

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

src/libirecovery.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1089,15 +1089,14 @@ static irecv_error_t win32_open_with_ecid(irecv_client_t* client, uint64_t ecid)
10891089
{
10901090
int found = 0;
10911091
const GUID *guids[] = { &GUID_DEVINTERFACE_DFU, &GUID_DEVINTERFACE_IBOOT, NULL };
1092-
SP_DEVICE_INTERFACE_DATA currentInterface;
1093-
HDEVINFO usbDevices;
1094-
DWORD i;
10951092
irecv_client_t _client = (irecv_client_t) malloc(sizeof(struct irecv_client_private));
10961093
memset(_client, 0, sizeof(struct irecv_client_private));
10971094

10981095
int k;
10991096
for (k = 0; !found && guids[k]; k++) {
1100-
usbDevices = SetupDiGetClassDevs(guids[k], NULL, NULL, DIGCF_PRESENT | DIGCF_DEVICEINTERFACE);
1097+
DWORD i;
1098+
SP_DEVICE_INTERFACE_DATA currentInterface;
1099+
HDEVINFO usbDevices = SetupDiGetClassDevs(guids[k], NULL, NULL, DIGCF_PRESENT | DIGCF_DEVICEINTERFACE);
11011100
memset(&currentInterface, '\0', sizeof(SP_DEVICE_INTERFACE_DATA));
11021101
currentInterface.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA);
11031102
for (i = 0; usbDevices && SetupDiEnumDeviceInterfaces(usbDevices, NULL, guids[k], i, &currentInterface); i++) {
@@ -1193,8 +1192,8 @@ static irecv_error_t win32_open_with_ecid(irecv_client_t* client, uint64_t ecid)
11931192
found = 1;
11941193
break;
11951194
}
1195+
SetupDiDestroyDeviceInfoList(usbDevices);
11961196
}
1197-
SetupDiDestroyDeviceInfoList(usbDevices);
11981197

11991198
if (!found) {
12001199
irecv_close(_client);

0 commit comments

Comments
 (0)