1
0
mirror of https://github.com/GOSTSec/sgminer synced 2025-01-11 07:17:58 +00:00

Although async transfers are meant to use heap memory, we never return before the transfer function has completed so stack memory will suffice for control transfers, fixing a memory leak in the process.

This commit is contained in:
Con Kolivas 2013-10-12 15:06:48 +11:00
parent 56edabc64d
commit 84f642f563

View File

@ -2712,12 +2712,9 @@ static int usb_control_transfer(libusb_device_handle *dev_handle, uint8_t bmRequ
unsigned char *buffer, uint16_t wLength, unsigned int timeout) unsigned char *buffer, uint16_t wLength, unsigned int timeout)
{ {
struct usb_transfer ut; struct usb_transfer ut;
unsigned char buf[70];
int err, transferred; int err, transferred;
unsigned char *buf;
buf = malloc(70);
if (unlikely(!buf))
quit(1, "Failed to malloc buf in usb_control_transfer");
init_usb_transfer(&ut); init_usb_transfer(&ut);
mutex_lock(&ut.mutex); mutex_lock(&ut.mutex);
libusb_fill_control_setup(buf, bmRequestType, bRequest, wValue, libusb_fill_control_setup(buf, bmRequestType, bRequest, wValue,