summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2024-01-04 02:10:57 +0100
committerGravatar GitHub2024-01-04 02:10:57 +0100
commit15fdc6ae46884208ef060dc84e32daa15e20ded8 (patch)
tree52dda0cf7374ff273c2d28857c77ead6ab85524c
parent2fff42619eb1bed0c1664c138414320bdb37a486 (diff)
downloadlibirecovery-15fdc6ae46884208ef060dc84e32daa15e20ded8.tar.gz
libirecovery-15fdc6ae46884208ef060dc84e32daa15e20ded8.tar.bz2
win32: Make sure to free device list at the right place
-rw-r--r--src/libirecovery.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/libirecovery.c b/src/libirecovery.c
index 0babf1d..7ddb2b5 100644
--- a/src/libirecovery.c
+++ b/src/libirecovery.c
@@ -1089,15 +1089,14 @@ static irecv_error_t win32_open_with_ecid(irecv_client_t* client, uint64_t ecid)
{
int found = 0;
const GUID *guids[] = { &GUID_DEVINTERFACE_DFU, &GUID_DEVINTERFACE_IBOOT, NULL };
- SP_DEVICE_INTERFACE_DATA currentInterface;
- HDEVINFO usbDevices;
- DWORD i;
irecv_client_t _client = (irecv_client_t) malloc(sizeof(struct irecv_client_private));
memset(_client, 0, sizeof(struct irecv_client_private));
int k;
for (k = 0; !found && guids[k]; k++) {
- usbDevices = SetupDiGetClassDevs(guids[k], NULL, NULL, DIGCF_PRESENT | DIGCF_DEVICEINTERFACE);
+ DWORD i;
+ SP_DEVICE_INTERFACE_DATA currentInterface;
+ HDEVINFO usbDevices = SetupDiGetClassDevs(guids[k], NULL, NULL, DIGCF_PRESENT | DIGCF_DEVICEINTERFACE);
memset(&currentInterface, '\0', sizeof(SP_DEVICE_INTERFACE_DATA));
currentInterface.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA);
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)
found = 1;
break;
}
+ SetupDiDestroyDeviceInfoList(usbDevices);
}
- SetupDiDestroyDeviceInfoList(usbDevices);
if (!found) {
irecv_close(_client);