From 59ce14522ba6f13d2877e8e37513031109adda16 Mon Sep 17 00:00:00 2001 From: Roland Knall Date: Thu, 21 Nov 2019 12:35:29 +0100 Subject: [PATCH] Qt: Fix nullpointer access Due to changes with the frameSelect, this null pointer check now fails or more on the point is more obvious. It was masked previous Change-Id: I11c3f3440e39742bce963d1ef8bdd27076baa700 Reviewed-on: https://code.wireshark.org/review/35177 Petri-Dish: Roland Knall Tested-by: Petri Dish Buildbot Reviewed-by: Roland Knall --- ui/qt/main_window_slots.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/ui/qt/main_window_slots.cpp b/ui/qt/main_window_slots.cpp index 4d8cd8368b..8d29ce6b8a 100644 --- a/ui/qt/main_window_slots.cpp +++ b/ui/qt/main_window_slots.cpp @@ -1160,7 +1160,6 @@ void MainWindow::setMenusForSelectedPacket() << main_ui_->actionViewColorizeConversation9 << main_ui_->actionViewColorizeConversation10; if (capture_file_.capFile()) { - QList rows = selectedRows(); frame_data * current_frame = 0; if (rows.count() > 0) @@ -1209,8 +1208,12 @@ void MainWindow::setMenusForSelectedPacket() main_ui_->actionEditNextMark->setEnabled(another_is_marked); main_ui_->actionEditPreviousMark->setEnabled(another_is_marked); - main_ui_->actionEditPacketComment->setEnabled(frame_selected && wtap_dump_can_write(capture_file_.capFile()->linktypes, WTAP_COMMENT_PER_PACKET)); - main_ui_->actionDeleteAllPacketComments->setEnabled((capture_file_.capFile() != NULL) && wtap_dump_can_write(capture_file_.capFile()->linktypes, WTAP_COMMENT_PER_PACKET)); + GArray * linkTypes = Q_NULLPTR; + if (capture_file_.capFile() && capture_file_.capFile()->linktypes) + linkTypes = capture_file_.capFile()->linktypes; + + main_ui_->actionEditPacketComment->setEnabled(frame_selected && linkTypes && wtap_dump_can_write(capture_file_.capFile()->linktypes, WTAP_COMMENT_PER_PACKET)); + main_ui_->actionDeleteAllPacketComments->setEnabled(linkTypes && wtap_dump_can_write(capture_file_.capFile()->linktypes, WTAP_COMMENT_PER_PACKET)); main_ui_->actionEditIgnorePacket->setEnabled(frame_selected || multi_selection); main_ui_->actionEditIgnoreAllDisplayed->setEnabled(have_filtered);