summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDenis Shienkov <denis.shienkov@gmail.com>2015-06-26 11:30:19 +0300
committerDenis Shienkov <denis.shienkov@gmail.com>2015-06-29 14:17:10 +0000
commita7a4fa4b628526a5d9138ed56bb195be71bac118 (patch)
tree4dc4488d5561cd4beaecbfb1b434c86a4e71385b /src
parente9566e39dcec4a575d2d44f103562e60e760574f (diff)
Fix crash in QSPI::availablePorts() on OS X 10.10
CFTypeRef returned by IORegistryEntrySearchCFProperty sometimes may be of unexpected type (as CFStringRef instead of CFNumberRef). In this case the CFNumberGetValue() throws the exception. The simplest fix is to check the type in searchShortIntProperty() before calling CFNumberGetValue(): CFGetTypeID(result.as<CFNumberRef>()) == CFNumberGetTypeID(). Thanks to Orest Hera. Task-number: QTBUG-46875 Change-Id: Id86993c008595f9762a08739bf4c5f5662643e92 Reviewed-by: Dyami Caliri <dyami@dragonframe.com> Reviewed-by: Jake Petroules <jake.petroules@petroules.com>
Diffstat (limited to 'src')
-rw-r--r--src/serialport/qserialportinfo_mac.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/serialport/qserialportinfo_mac.cpp b/src/serialport/qserialportinfo_mac.cpp
index 558dcbd0..8d4034a5 100644
--- a/src/serialport/qserialportinfo_mac.cpp
+++ b/src/serialport/qserialportinfo_mac.cpp
@@ -72,9 +72,10 @@ static quint16 searchShortIntProperty(io_registry_entry_t ioRegistryEntry,
bool &ok)
{
const QCFType<CFTypeRef> result(searchProperty(ioRegistryEntry, propertyKey));
+ const CFNumberRef ref = result.as<CFNumberRef>();
quint16 value = 0;
- ok = result.as<CFNumberRef>()
- && (::CFNumberGetValue(result.as<CFNumberRef>(), kCFNumberShortType, &value) > 0);
+ ok = ref && (::CFGetTypeID(ref) == ::CFNumberGetTypeID())
+ && (::CFNumberGetValue(ref, kCFNumberShortType, &value) > 0);
return value;
}