From 1d02741879d7d8c956ce2c5ace31048ae790a6d3 Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Sat, 9 Jul 2016 14:54:08 -0700 Subject: [PATCH] Fix crash in HIDListenerIOKit when wLenDone == 0 --- lib/inputdev/HIDListenerIOKit.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/inputdev/HIDListenerIOKit.cpp b/lib/inputdev/HIDListenerIOKit.cpp index 9b35408..d4afb27 100644 --- a/lib/inputdev/HIDListenerIOKit.cpp +++ b/lib/inputdev/HIDListenerIOKit.cpp @@ -43,6 +43,9 @@ static bool getUSBStringDescriptor(IOUSBDeviceInterface182** usbDevice, UInt8 id // we're mallocing this string just as an example. But you probably will want // to do something smarter, like pre-allocated buffers in the info class, or // use a string class. + if (request.wLenDone == 0) + return false; + unsigned count = (request.wLenDone - 1) / 2; unsigned i; for (i=0 ; i