summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Shienkov <denis.shienkov@gmail.com>2015-06-26 17:10:27 +0300
committerDenis Shienkov <denis.shienkov@gmail.com>2015-06-29 15:04:19 +0000
commitbc948f5f695908ad11a19b1336975d07ff1de0e1 (patch)
treecd7e5973a335020bd2ff0403f85e8d2e618e5971
parenta7a4fa4b628526a5d9138ed56bb195be71bac118 (diff)
downloadqtserialport-bc948f5f695908ad11a19b1336975d07ff1de0e1.tar.gz
Check on CFStringRef type before of QString creation
It is make sense to check the returned QCFType<CFTypeRef> property on the null-pointer and on the CFStringRef type to exclude of possible exception. Thanks to Orest Hera. Change-Id: I09f784b9ce8aa471dfb53181798d0066945efc86 Reviewed-by: Dyami Caliri <dyami@dragonframe.com> Reviewed-by: Jake Petroules <jake.petroules@petroules.com>
-rw-r--r--src/serialport/qserialportinfo_mac.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/serialport/qserialportinfo_mac.cpp b/src/serialport/qserialportinfo_mac.cpp
index 8d4034a..e917545 100644
--- a/src/serialport/qserialportinfo_mac.cpp
+++ b/src/serialport/qserialportinfo_mac.cpp
@@ -64,7 +64,11 @@ static QCFType<CFTypeRef> searchProperty(io_registry_entry_t ioRegistryEntry,
static QString searchStringProperty(io_registry_entry_t ioRegistryEntry,
const QCFString &propertyKey)
{
- return QCFString::toQString(searchProperty(ioRegistryEntry, propertyKey).as<CFStringRef>());
+ const QCFType<CFTypeRef> result(searchProperty(ioRegistryEntry, propertyKey));
+ const CFStringRef ref = result.as<CFStringRef>();
+ if (ref && (::CFGetTypeID(ref) == ::CFStringGetTypeID()))
+ return QCFString::toQString(ref);
+ return QString();
}
static quint16 searchShortIntProperty(io_registry_entry_t ioRegistryEntry,