Skip to content

Commit 5d9b4cd

Browse files
aeikumQbicz
authored andcommitted
Zero-initialize new hid_device_info structs
This fixes an uninitialized usage_page value leaking from the Linux backend. It may fix other uninitialized values, too.
1 parent 93dca80 commit 5d9b4cd

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

linux/hid.c

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

478478
/* VID/PID match. Create the record. */
479-
tmp = (struct hid_device_info*) malloc(sizeof(struct hid_device_info));
479+
tmp = (struct hid_device_info*) calloc(1, sizeof(struct hid_device_info));
480480
if (cur_dev) {
481481
cur_dev->next = tmp;
482482
}

mac/hid.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ struct hid_device_info HID_API_EXPORT *hid_enumerate(unsigned short vendor_id,
440440
io_string_t path;
441441

442442
/* VID/PID match. Create the record. */
443-
tmp = (struct hid_device_info*) malloc(sizeof(struct hid_device_info));
443+
tmp = (struct hid_device_info*) calloc(1, sizeof(struct hid_device_info));
444444
if (cur_dev) {
445445
cur_dev->next = tmp;
446446
}

0 commit comments

Comments
 (0)