Index: device/hid/hid_connection_linux.cc |
diff --git a/device/hid/hid_connection_linux.cc b/device/hid/hid_connection_linux.cc |
index ec348ed6abc4cc5a429f74bd65c012c0ba0b096e..62d06c35d6a7610d9227ac6b918774e2658b9105 100644 |
--- a/device/hid/hid_connection_linux.cc |
+++ b/device/hid/hid_connection_linux.cc |
@@ -242,6 +242,12 @@ void HidConnectionLinux::PlatformSendFeatureReport( |
void HidConnectionLinux::ProcessInputReport(scoped_refptr<net::IOBuffer> buffer, |
size_t size) { |
DCHECK(thread_checker().CalledOnValidThread()); |
+ DCHECK_GE(size, 1u); |
+ |
+ uint8_t report_id = buffer->data()[0]; |
+ if (IsReportIdProtected(report_id)) |
+ return; |
+ |
PendingHidReport report; |
report.buffer = buffer; |
report.size = size; |
@@ -251,13 +257,17 @@ void HidConnectionLinux::ProcessInputReport(scoped_refptr<net::IOBuffer> buffer, |
void HidConnectionLinux::ProcessReadQueue() { |
DCHECK(thread_checker().CalledOnValidThread()); |
+ |
+ // Hold a reference to |this| to prevent a callback from freeing this object |
+ // during the loop. |
+ scoped_refptr<HidConnectionLinux> self(this); |
while (pending_reads_.size() && pending_reports_.size()) { |
PendingHidRead read = pending_reads_.front(); |
PendingHidReport report = pending_reports_.front(); |
+ pending_reads_.pop(); |
pending_reports_.pop(); |
- if (CompleteRead(report.buffer, report.size, read.callback)) |
- pending_reads_.pop(); |
+ read.callback.Run(true, report.buffer, report.size); |
} |
} |