From 15fdc6ae46884208ef060dc84e32daa15e20ded8 Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Thu, 4 Jan 2024 02:10:57 +0100 Subject: win32: Make sure to free device list at the right place --- src/libirecovery.c | 9 ++++----- 1 file 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(¤tInterface, '\0', sizeof(SP_DEVICE_INTERFACE_DATA)); currentInterface.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA); for (i = 0; usbDevices && SetupDiEnumDeviceInterfaces(usbDevices, NULL, guids[k], i, ¤tInterface); 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); -- cgit v1.1-32-gdbae