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 19:26:58 +0000
commit3f9fabb7dafa9bc0c8965d476152491b70ee04a7 (patch)
tree16938db7f1826ebd89d812447beff45ffdc145fc
parente63f2f213ae1ab79b051ccf355c58ed6a305de55 (diff)
downloadqtserialport-3f9fabb7dafa9bc0c8965d476152491b70ee04a7.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. (cherry-picked from bc948f5f695908ad11a19b1336975d07ff1de0e1) Change-Id: I09f784b9ce8aa471dfb53181798d0066945efc86 Reviewed-by: Denis Shienkov <denis.shienkov@gmail.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 3f242f1..a07db06 100644
--- a/src/serialport/qserialportinfo_mac.cpp
+++ b/src/serialport/qserialportinfo_mac.cpp
@@ -72,7 +72,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,