Skip to content

Commit 0e9560a

Browse files
committed
hidapi: Zero out new hid_device_info structs
1 parent bf9bf60 commit 0e9560a

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/hidapi/linux/hid.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ struct hid_device_info HID_API_EXPORT *hid_enumerate(unsigned short vendor_id,
547547
struct hid_device_info *tmp;
548548

549549
/* VID/PID match. Create the record. */
550-
tmp = (struct hid_device_info *)malloc(sizeof(struct hid_device_info));
550+
tmp = (struct hid_device_info *)calloc(1, sizeof(struct hid_device_info));
551551
if (cur_dev) {
552552
cur_dev->next = tmp;
553553
}

src/hidapi/mac/hid.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ struct hid_device_info HID_API_EXPORT *hid_enumerate(unsigned short vendor_id,
472472
size_t len;
473473

474474
/* VID/PID match. Create the record. */
475-
tmp = (struct hid_device_info *)malloc(sizeof(struct hid_device_info));
475+
tmp = (struct hid_device_info *)calloc(1, sizeof(struct hid_device_info));
476476
if (cur_dev) {
477477
cur_dev->next = tmp;
478478
}

0 commit comments

Comments
 (0)