Skip to content

Commit bb236dc

Browse files
committed
check for buffer early
1 parent 6a12c71 commit bb236dc

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

mac/hid.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1105,13 +1105,13 @@ static int set_report(hid_device *dev, IOHIDReportType type, const unsigned char
11051105
IOReturn res;
11061106
unsigned char report_id;
11071107

1108-
register_device_error(dev, NULL);
1109-
11101108
if (!data || (length == 0)) {
11111109
register_device_error(dev, "Zero buffer/length");
11121110
return -1;
11131111
}
11141112

1113+
register_device_error(dev, NULL);
1114+
11151115
report_id = data[0];
11161116

11171117
if (report_id == 0x0) {
@@ -1145,15 +1145,17 @@ static int get_report(hid_device *dev, IOHIDReportType type, unsigned char *data
11451145
unsigned char *report = data;
11461146
CFIndex report_length = length;
11471147
IOReturn res = kIOReturnSuccess;
1148-
const unsigned char report_id = data[0];
1149-
1150-
register_device_error(dev, NULL);
1148+
const unsigned char report_id;
11511149

11521150
if (!data || (length == 0)) {
11531151
register_device_error(dev, "Zero buffer/length");
11541152
return -1;
11551153
}
11561154

1155+
register_device_error(dev, NULL);
1156+
1157+
report_id = data[0];
1158+
11571159
if (report_id == 0x0) {
11581160
/* Not using numbered Reports.
11591161
Don't send the report number. */

0 commit comments

Comments
 (0)