diff --git a/src/bluetooth/qbluetoothtransferreply_bluez.cpp b/src/bluetooth/qbluetoothtransferreply_bluez.cpp index f0806d5eb4d405c062aed89ff86081072c77e01a..43a83d715bc284bfa28c3e5de551dd0e5246fd69 100644 --- a/src/bluetooth/qbluetoothtransferreply_bluez.cpp +++ b/src/bluetooth/qbluetoothtransferreply_bluez.cpp @@ -70,6 +70,14 @@ QBluetoothTransferReplyBluez::QBluetoothTransferReplyBluez(QIODevice *input, con setRequest(request); setManager(parent); + if (!input) { + qCWarning(QT_BT_BLUEZ) << "Invalid input device (null)"; + m_errorStr = QBluetoothTransferReply::tr("Invalid input device (null)"); + m_error = QBluetoothTransferReply::FileNotFoundError; + m_finished = true; + return; + } + if (isBluez5()) { m_clientBluez = new OrgBluezObexClient1Interface(QStringLiteral("org.bluez.obex"), QStringLiteral("/org/bluez/obex"), diff --git a/src/bluetooth/qbluetoothtransferreply_qnx.cpp b/src/bluetooth/qbluetoothtransferreply_qnx.cpp index 9a717f69c230e631433a7cd7f8afcb3bddd22800..d0e763cdf3c36d8cdc12863ff161d83f67329fa9 100644 --- a/src/bluetooth/qbluetoothtransferreply_qnx.cpp +++ b/src/bluetooth/qbluetoothtransferreply_qnx.cpp @@ -65,6 +65,15 @@ QBluetoothTransferReplyQnx::QBluetoothTransferReplyQnx(QIODevice *input, const Q { setRequest(request); setManager(parent); + + if (!input) { + qCWarning(QT_BT_QNX) << "Invalid input device (null)"; + m_errorStr = QBluetoothTransferReply::tr("Invalid input device (null)"); + m_error = QBluetoothTransferReply::FileNotFoundError; + m_finished = true; + return; + } + ppsRegisterControl(); //qsrand(QTime::currentTime().msec()); //m_agent_path = agentPath; diff --git a/tests/auto/qbluetoothtransfermanager/tst_qbluetoothtransfermanager.cpp b/tests/auto/qbluetoothtransfermanager/tst_qbluetoothtransfermanager.cpp index b2c55da593587a5f2f8a7ac356a3d0498e471ecd..b39e6292397fd414029691eb122fdbc4778ec648 100644 --- a/tests/auto/qbluetoothtransfermanager/tst_qbluetoothtransfermanager.cpp +++ b/tests/auto/qbluetoothtransfermanager/tst_qbluetoothtransfermanager.cpp @@ -84,6 +84,8 @@ private slots: void tst_sendBuffer_data(); void tst_sendBuffer(); + + void tst_sendNullPointer(); private: QBluetoothAddress remoteAddress; }; @@ -344,6 +346,20 @@ void tst_QBluetoothTransferManager::tst_sendBuffer() QVERIFY(!reply->isRunning()); } +void tst_QBluetoothTransferManager::tst_sendNullPointer() +{ + QBluetoothTransferRequest request(remoteAddress); + QBluetoothTransferManager manager; + QBluetoothTransferReply *reply = manager.put(request, 0); + + QVERIFY(reply); + QCOMPARE(reply->isFinished(), true); + QCOMPARE(reply->isRunning(), false); + QCOMPARE(reply->manager(), &manager); + QCOMPARE(reply->request(), request); + QCOMPARE(reply->error(), QBluetoothTransferReply::FileNotFoundError); +} + QTEST_MAIN(tst_QBluetoothTransferManager) #include "tst_qbluetoothtransfermanager.moc"