Replaced malloc in urbdrc channel

(cherry picked from commit 3ae6feeebe8638c3bea76fd270f3fd46ee768ff2)
This commit is contained in:
akallabeth 2020-07-03 16:20:12 +02:00
parent 059c4ed46d
commit 252c793c01
2 changed files with 5 additions and 3 deletions

View File

@ -457,8 +457,10 @@ static LIBUSB_DEVICE* udev_get_libusb_dev(libusb_context* context, uint8_t bus_n
static LIBUSB_DEVICE_DESCRIPTOR* udev_new_descript(URBDRC_PLUGIN* urbdrc, LIBUSB_DEVICE* libusb_dev)
{
int ret;
LIBUSB_DEVICE_DESCRIPTOR* descriptor;
descriptor = (LIBUSB_DEVICE_DESCRIPTOR*)malloc(sizeof(LIBUSB_DEVICE_DESCRIPTOR));
LIBUSB_DEVICE_DESCRIPTOR* descriptor =
(LIBUSB_DEVICE_DESCRIPTOR*)calloc(1, sizeof(LIBUSB_DEVICE_DESCRIPTOR));
if (!descriptor)
return NULL;
ret = libusb_get_device_descriptor(libusb_dev, descriptor);
if (log_libusb_result(urbdrc->log, WLOG_ERROR, "libusb_get_device_descriptor", ret))

View File

@ -665,7 +665,7 @@ static BOOL urbdrc_udevman_register_devices(UDEVMAN* udevman, const char* device
}
else
{
idpair = malloc(sizeof(VID_PID_PAIR));
idpair = calloc(1, sizeof(VID_PID_PAIR));
if (!idpair)
return CHANNEL_RC_NO_MEMORY;
idpair->vid = id1;