summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Solovev <ivan.solovev@qt.io>2023-04-04 16:36:17 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2023-04-05 08:37:28 +0000
commita128e35291c771a4165b092788f3ca30d3a17511 (patch)
tree9af6de20bce3d0ffaa815b1752c2d3b2652107cc
parenta3545438369c3fc13dc6190dffa98adb5f5321e4 (diff)
downloadqtconnectivity-a128e35291c771a4165b092788f3ca30d3a17511.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. Change-Id: If1650a927e094a0b5349ecb6a8288531479ae1a5 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Juha Vuolle <juha.vuolle@qt.io> (cherry picked from commit 7be77bb98e4e272de1fd6d6d8e70058ff52363e7) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-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;