Replaced malloc in urbdrc channel
authorakallabeth <akallabeth@posteo.net>
Fri, 3 Jul 2020 14:20:12 +0000 (16:20 +0200)
committerakallabeth <akallabeth@posteo.net>
Tue, 7 Jul 2020 08:44:12 +0000 (10:44 +0200)
(cherry picked from commit 3ae6feeebe8638c3bea76fd270f3fd46ee768ff2)

channels/urbdrc/client/libusb/libusb_udevice.c
channels/urbdrc/client/libusb/libusb_udevman.c

index c1f4533..c4d5c6b 100644 (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))
index 973d9c1..2eebc1a 100644 (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;