diff options
author | Stig Bjørlykke <stig@bjorlykke.org> | 2021-10-01 10:31:30 +0200 |
---|---|---|
committer | Wireshark GitLab Utility <gerald+gitlab-utility@wireshark.org> | 2021-10-01 17:16:13 +0000 |
commit | ec2746c910059169fa528466e8187643105ba56d (patch) | |
tree | 6cae4e4b77ea235e066f06b1e2eb276051fd4b13 /ui | |
parent | c7dc907d0e31d801d2b51aea871aace6df0c0c05 (diff) |
capture: Check for valid wtap when capture.show_info
Changing profile during capture may change the capture_opts->show_info
setting. Always init cap_session->wtap and check if valid before doing
capture_info_new_packets(). Always close dialog and cap_session->wtap
in capture_input_closed().
This will not bring up the Capture Information dialog when switching
to a profile having this enabled.
Fixes #17622
Diffstat (limited to 'ui')
-rw-r--r-- | ui/capture.c | 14 | ||||
-rw-r--r-- | ui/qt/capture_info_dialog.cpp | 1 |
2 files changed, 8 insertions, 7 deletions
diff --git a/ui/capture.c b/ui/capture.c index 8d6cc030f7..5a5c6a2015 100644 --- a/ui/capture.c +++ b/ui/capture.c @@ -153,9 +153,9 @@ capture_start(capture_options *capture_opts, GPtrArray *capture_comments, wtap_rec_init(&cap_session->rec); ws_buffer_init(&cap_session->buf, 1514); - if (capture_opts->show_info) { - cap_session->wtap = NULL; + cap_session->wtap = NULL; + if (capture_opts->show_info) { if (cap_data->counts.counts_hash != NULL) { /* Clean up any previous lists of packet counts */ @@ -549,7 +549,7 @@ capture_input_new_packets(capture_session *cap_session, int to_read) capture_callback_invoke(capture_cb_capture_fixed_continue, cap_session); } - if(capture_opts->show_info) + if(cap_session->wtap) capture_info_new_packets(to_read, cap_session->wtap, cap_session->cap_data_info); } @@ -748,10 +748,10 @@ capture_input_closed(capture_session *cap_session, gchar *msg) } } - if(capture_opts->show_info) { - capture_info_ui_destroy(&cap_session->cap_data_info->ui); - if(cap_session->wtap) - wtap_close(cap_session->wtap); + capture_info_ui_destroy(&cap_session->cap_data_info->ui); + if(cap_session->wtap) { + wtap_close(cap_session->wtap); + cap_session->wtap = NULL; } cap_session->state = CAPTURE_STOPPED; diff --git a/ui/qt/capture_info_dialog.cpp b/ui/qt/capture_info_dialog.cpp index fdba3a870f..8c4ef8a8de 100644 --- a/ui/qt/capture_info_dialog.cpp +++ b/ui/qt/capture_info_dialog.cpp @@ -78,6 +78,7 @@ capture_info *cinfo) { CaptureInfoDialog *ci_dlg = qobject_cast<CaptureInfoDialog *>((QObject *)cinfo->ui); if (!ci_dlg) return; + cinfo->ui = NULL; delete ci_dlg; } |