Details
-
Bug
-
Resolution: Done
-
P2: Important
-
5.2.1, 5.4.2
-
None
-
OS X 10.10
Description
CFTypeRef returned by IORegistryEntrySearchCFProperty sometimes may be of unexpected type.
That leads to exception and/or crash with some USB devices when product id is parsed in the internal loop of QSerialPortInfo::availablePorts() in qserialportinfo_mac.cpp.
Console output is attached:
- main-thread.log: the exception when the availablePorts function is called from the main thread;
- qthread-crash.log: the crash when the availablePorts function is called from QThread.
It occurred by checking type with CFGetTypeID() that returned type of CFTypeRef corresponds to CFString instead of CFNumber for kUSBProductID during the first internal loop run. CFNumberRef is returned only during the second loop run.
So, CFStringRef is used as an argument for CFNumberGetValue() instead of CFNumberRef.
On OS X versions before 10.10 the wrong type was handled by CFNumberGetValue(). The return value was 'false'. So, on Qt5.2.1 the hasProductIdentifier field was 'false', and on Qt5.4.2 the product id was correct.
Starting from OS X 10.10 CFNumberGetValue() throws the exception in that case and there is no a workaround.
The simplest fix is to check the type in searchShortIntProperty() before calling CFNumberGetValue():
CFGetTypeID(result.as<CFNumberRef>()) == CFNumberGetTypeID().