Qt: unchecked dynamic cast

Dynamic cast may yield NULL pointer, hence must be checked before
dereferencing it. Easy enough in a conditional.

CID 1435488

Change-Id: I8359ab5865795f1b1bea6980b023ff636d6719a6
Reviewed-on: https://code.wireshark.org/review/33316
Reviewed-by: Jaap Keuter <jaap.keuter@xs4all.nl>
Petri-Dish: Jaap Keuter <jaap.keuter@xs4all.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Gerald Combs <gerald@wireshark.org>
This commit is contained in:
Jaap Keuter 2019-05-22 22:13:30 +02:00 committed by Gerald Combs
parent f12ec0c9a3
commit 29283decd7
1 changed files with 2 additions and 2 deletions

View File

@ -351,8 +351,8 @@ public:
WlanStationTreeWidgetItem* receiver_ws_ti = NULL;
foreach (QTreeWidgetItem *cur_ti, stations_) {
WlanStationTreeWidgetItem *cur_ws_ti = dynamic_cast<WlanStationTreeWidgetItem *>(cur_ti);
if (cur_ws_ti->isMatch(&wlan_hdr->src)) sender_ws_ti = cur_ws_ti;
if (cur_ws_ti->isMatch(&wlan_hdr->dst)) receiver_ws_ti = cur_ws_ti;
if (cur_ws_ti && (cur_ws_ti->isMatch(&wlan_hdr->src))) sender_ws_ti = cur_ws_ti;
if (cur_ws_ti && (cur_ws_ti->isMatch(&wlan_hdr->dst))) receiver_ws_ti = cur_ws_ti;
if (sender_ws_ti && receiver_ws_ti) break;
}
if (!sender_ws_ti) {