diff options
author | Oliver Wolff <oliver.wolff@qt.io> | 2017-08-01 15:44:13 +0200 |
---|---|---|
committer | Oliver Wolff <oliver.wolff@qt.io> | 2017-08-02 05:55:48 +0000 |
commit | e9cb913a37318284353790f46edc648a630d758f (patch) | |
tree | c1cfbc86c1ae9c91baee6dbd35960ad0cf72f3f8 | |
parent | 8646dd8a830225b1697dc1cafff32bba0ade84c5 (diff) |
winrt: Check for valid m_socketObject before accessing socket information
If the socket was created without giving the socket type,
ensureNativeSocket was not called and thus m_socketObject is 0. Calling
localName and friends caused a crash because they accesses the object
unconditionally.
Change-Id: I442e3d1492458161fb8660f1b2f17d52b37a2935
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
-rw-r--r-- | src/bluetooth/qbluetoothsocket_winrt.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/bluetooth/qbluetoothsocket_winrt.cpp b/src/bluetooth/qbluetoothsocket_winrt.cpp index 4a9d1b93..501ffd74 100644 --- a/src/bluetooth/qbluetoothsocket_winrt.cpp +++ b/src/bluetooth/qbluetoothsocket_winrt.cpp @@ -422,6 +422,9 @@ QString QBluetoothSocketPrivate::localName() const QBluetoothAddress QBluetoothSocketPrivate::localAddress() const { + if (!m_socketObject) + return QBluetoothAddress(); + HRESULT hr; ComPtr<IStreamSocketInformation> info; hr = m_socketObject->get_Information(&info); @@ -437,6 +440,9 @@ QBluetoothAddress QBluetoothSocketPrivate::localAddress() const quint16 QBluetoothSocketPrivate::localPort() const { + if (!m_socketObject) + return 0; + HRESULT hr; ComPtr<IStreamSocketInformation> info; hr = m_socketObject->get_Information(&info); @@ -449,6 +455,9 @@ quint16 QBluetoothSocketPrivate::localPort() const QString QBluetoothSocketPrivate::peerName() const { + if (!m_socketObject) + return QString(); + HRESULT hr; ComPtr<IStreamSocketInformation> info; hr = m_socketObject->get_Information(&info); @@ -464,6 +473,9 @@ QString QBluetoothSocketPrivate::peerName() const QBluetoothAddress QBluetoothSocketPrivate::peerAddress() const { + if (!m_socketObject) + return QBluetoothAddress(); + HRESULT hr; ComPtr<IStreamSocketInformation> info; hr = m_socketObject->get_Information(&info); @@ -479,6 +491,9 @@ QBluetoothAddress QBluetoothSocketPrivate::peerAddress() const quint16 QBluetoothSocketPrivate::peerPort() const { + if (!m_socketObject) + return 0; + HRESULT hr; ComPtr<IStreamSocketInformation> info; hr = m_socketObject->get_Information(&info); |