summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libusb/core.c3
-rw-r--r--libusb/io.c3
-rw-r--r--libusb/os/linux_usbfs.c12
-rw-r--r--libusb/version_nano.h2
4 files changed, 7 insertions, 13 deletions
diff --git a/libusb/core.c b/libusb/core.c
index e10d808..eccc216 100644
--- a/libusb/core.c
+++ b/libusb/core.c
@@ -1628,12 +1628,11 @@ int API_EXPORTED libusb_init(libusb_context **context)
return 0;
}
- ctx = malloc(sizeof(*ctx));
+ ctx = calloc(1, sizeof(*ctx));
if (!ctx) {
r = LIBUSB_ERROR_NO_MEM;
goto err_unlock;
}
- memset(ctx, 0, sizeof(*ctx));
#ifdef ENABLE_DEBUG_LOGGING
ctx->debug = LIBUSB_LOG_LEVEL_DEBUG;
diff --git a/libusb/io.c b/libusb/io.c
index d06d375..b8d445c 100644
--- a/libusb/io.c
+++ b/libusb/io.c
@@ -1232,11 +1232,10 @@ struct libusb_transfer * LIBUSB_CALL libusb_alloc_transfer(
+ sizeof(struct libusb_transfer)
+ (sizeof(struct libusb_iso_packet_descriptor) * iso_packets)
+ os_alloc_size;
- struct usbi_transfer *itransfer = malloc(alloc_size);
+ struct usbi_transfer *itransfer = calloc(1, alloc_size);
if (!itransfer)
return NULL;
- memset(itransfer, 0, alloc_size);
itransfer->num_iso_packets = iso_packets;
usbi_mutex_init(&itransfer->lock, NULL);
return USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
diff --git a/libusb/os/linux_usbfs.c b/libusb/os/linux_usbfs.c
index a01fff8..dad7536 100644
--- a/libusb/os/linux_usbfs.c
+++ b/libusb/os/linux_usbfs.c
@@ -1679,10 +1679,9 @@ static int submit_bulk_transfer(struct usbi_transfer *itransfer,
usbi_dbg("need %d urbs for new transfer with length %d", num_urbs,
transfer->length);
alloc_size = num_urbs * sizeof(struct usbfs_urb);
- urbs = malloc(alloc_size);
+ urbs = calloc(1, alloc_size);
if (!urbs)
return LIBUSB_ERROR_NO_MEM;
- memset(urbs, 0, alloc_size);
tpriv->urbs = urbs;
tpriv->num_urbs = num_urbs;
tpriv->num_retired = 0;
@@ -1808,10 +1807,9 @@ static int submit_iso_transfer(struct usbi_transfer *itransfer)
usbi_dbg("need %d 32k URBs for transfer", num_urbs);
alloc_size = num_urbs * sizeof(*urbs);
- urbs = malloc(alloc_size);
+ urbs = calloc(1, alloc_size);
if (!urbs)
return LIBUSB_ERROR_NO_MEM;
- memset(urbs, 0, alloc_size);
tpriv->iso_urbs = urbs;
tpriv->num_urbs = num_urbs;
@@ -1845,12 +1843,11 @@ static int submit_iso_transfer(struct usbi_transfer *itransfer)
alloc_size = sizeof(*urb)
+ (urb_packet_offset * sizeof(struct usbfs_iso_packet_desc));
- urb = malloc(alloc_size);
+ urb = calloc(1, alloc_size);
if (!urb) {
free_iso_urbs(tpriv);
return LIBUSB_ERROR_NO_MEM;
}
- memset(urb, 0, alloc_size);
urbs[i] = urb;
/* populate packet lengths */
@@ -1934,10 +1931,9 @@ static int submit_control_transfer(struct usbi_transfer *itransfer)
if (transfer->length - LIBUSB_CONTROL_SETUP_SIZE > MAX_CTRL_BUFFER_LENGTH)
return LIBUSB_ERROR_INVALID_PARAM;
- urb = malloc(sizeof(struct usbfs_urb));
+ urb = calloc(1, sizeof(struct usbfs_urb));
if (!urb)
return LIBUSB_ERROR_NO_MEM;
- memset(urb, 0, sizeof(struct usbfs_urb));
tpriv->urbs = urb;
tpriv->num_urbs = 1;
tpriv->reap_action = NORMAL;
diff --git a/libusb/version_nano.h b/libusb/version_nano.h
index 6fc6748..e6ad1ad 100644
--- a/libusb/version_nano.h
+++ b/libusb/version_nano.h
@@ -1 +1 @@
-#define LIBUSB_NANO 10537
+#define LIBUSB_NANO 10538