mirror of
https://github.com/aaru-dps/aaruremote.git
synced 2025-12-16 19:24:37 +00:00
Store device type GUIDs in heap, old version of compiler do not support GUID arrays in stack.
This commit is contained in:
24
win32/usb.c
24
win32/usb.c
@@ -607,15 +607,17 @@ uint8_t GetUsbData(void* device_ctx,
|
||||
char* product,
|
||||
char* serial)
|
||||
{
|
||||
DeviceContext* ctx = device_ctx;
|
||||
UsbDevice_t* device = NULL;
|
||||
GUID floppyGuid = GUID_DEVINTERFACE_FLOPPY;
|
||||
GUID tapeGuid = GUID_DEVINTERFACE_TAPE;
|
||||
GUID diskGuid = GUID_DEVINTERFACE_DISK;
|
||||
GUID cdromGuid = GUID_DEVINTERFACE_CDROM;
|
||||
GUID guids[4] = {floppyGuid, cdromGuid, diskGuid, tapeGuid};
|
||||
DeviceContext* ctx = device_ctx;
|
||||
UsbDevice_t* device = NULL;
|
||||
GUID* guids;
|
||||
int i;
|
||||
|
||||
guids = malloc(sizeof(GUID) * 4);
|
||||
guids[0] = GUID_DEVINTERFACE_FLOPPY;
|
||||
guids[1] = GUID_DEVINTERFACE_CDROM;
|
||||
guids[2] = GUID_DEVINTERFACE_DISK;
|
||||
guids[3] = GUID_DEVINTERFACE_TAPE;
|
||||
|
||||
if(!ctx) return -1;
|
||||
|
||||
for(i = 0; i < 4; i++)
|
||||
@@ -625,7 +627,11 @@ uint8_t GetUsbData(void* device_ctx,
|
||||
if(device != NULL) break;
|
||||
}
|
||||
|
||||
if(device == NULL) return 0;
|
||||
if(device == NULL)
|
||||
{
|
||||
free(guids);
|
||||
return 0;
|
||||
}
|
||||
|
||||
memcpy(descriptors, device->BinaryDeviceDescriptors, device->BinaryDeviceDescriptorsLength);
|
||||
*desc_len = (uint16_t)device->BinaryDeviceDescriptorsLength;
|
||||
@@ -635,5 +641,7 @@ uint8_t GetUsbData(void* device_ctx,
|
||||
strncpy(product, device->Product, 256);
|
||||
strncpy(serial, device->SerialNumber, 256);
|
||||
|
||||
free(guids);
|
||||
|
||||
return 1;
|
||||
}
|
||||
Reference in New Issue
Block a user