summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Solovev <ivan.solovev@qt.io>2023-04-04 16:36:17 +0200
committerIvan Solovev <ivan.solovev@qt.io>2023-04-05 10:00:58 +0200
commit7be77bb98e4e272de1fd6d6d8e70058ff52363e7 (patch)
tree6eaabdbb0bda2e094fce11b2f423f8905ab24645
parentdd011e93e3f2868eaf99969cc9f782dcdb0bf2cf (diff)
downloadqtconnectivity-7be77bb98e4e272de1fd6d6d8e70058ff52363e7.tar.gz
BtChat: fix a potential crash when deleting uninitialized pointer
Initialize ChatServer pointer to nullptr, and also remove an explicit delete call, because the pointer will be managed by Qt. Pick-to: 6.5 Change-Id: If1650a927e094a0b5349ecb6a8288531479ae1a5 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
-rw-r--r--examples/bluetooth/btchat/chat.cpp1
-rw-r--r--examples/bluetooth/btchat/chat.h2
2 files changed, 1 insertions, 2 deletions
diff --git a/examples/bluetooth/btchat/chat.cpp b/examples/bluetooth/btchat/chat.cpp
index cdaa28d8..a9545cf6 100644
--- a/examples/bluetooth/btchat/chat.cpp
+++ b/examples/bluetooth/btchat/chat.cpp
@@ -74,7 +74,6 @@ Chat::Chat(QWidget *parent)
Chat::~Chat()
{
qDeleteAll(clients);
- delete server;
delete ui;
}
diff --git a/examples/bluetooth/btchat/chat.h b/examples/bluetooth/btchat/chat.h
index a9e99395..1c9d3211 100644
--- a/examples/bluetooth/btchat/chat.h
+++ b/examples/bluetooth/btchat/chat.h
@@ -45,7 +45,7 @@ private:
int currentAdapterIndex = 0;
Ui::Chat *ui;
- ChatServer *server;
+ ChatServer *server = nullptr;
QList<ChatClient *> clients;
QList<QBluetoothHostInfo> localAdapters;