summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStig Bjørlykke <stig@bjorlykke.org>2015-11-19 19:54:41 +0100
committerStig Bjørlykke <stig@bjorlykke.org>2015-11-20 07:58:07 +0000
commit9625a6f3a4e9e037c0d676147febf53d8091e567 (patch)
tree4672c826aa3f77c587772da03a91c7c71f58a683
parent270765811b1af619a59609b9dec8e6dd9c005ef3 (diff)
downloadwireshark-9625a6f3a4e9e037c0d676147febf53d8091e567.tar.gz
Qt: Fixed column issues when changing profile.
Always initialize prefs.col_list in pre_init_prefs. When switching to a profile without a saved 'preferences' file we have to initialize prefs.col_list to default values to avoid reusing settings from the profile we leave. This was introduced in 5012cf84e6d84a448171dac64c14d9c83e3d4ae6 Emit columnsChanged() before preferencesChanged(). This because columnsChanged() rebuilds cap_file_->cinfo which is used in preferencesChanged() to align columns (and possible other actions). Doing this in the wrong order will give an inconsistency and a heap-buffer-overflow if having different number of columns. Bug: 11493 Change-Id: I5792dfc0ede11b9457b96f092af8da00453787b1 Reviewed-on: https://code.wireshark.org/review/11971 Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org> (cherry picked from commit 0ae19656e12089271ea5941bcb4663bedc337b69) Reviewed-on: https://code.wireshark.org/review/11986
-rw-r--r--epan/prefs.c27
-rw-r--r--ui/qt/wireshark_application.cpp2
2 files changed, 15 insertions, 14 deletions
diff --git a/epan/prefs.c b/epan/prefs.c
index 9587f0877c..db02beb097 100644
--- a/epan/prefs.c
+++ b/epan/prefs.c
@@ -3040,20 +3040,21 @@ pre_init_prefs(void)
prefs.gui_qt_packet_list_separator = FALSE;
- if (!prefs.col_list) {
- /* First time through */
- for (i = 0; i < DEF_NUM_COLS; i++) {
- cfmt = g_new(fmt_data,1);
- cfmt->title = g_strdup(col_fmt[i * 2]);
- parse_column_format(cfmt, col_fmt[(i * 2) + 1]);
- cfmt->visible = TRUE;
- cfmt->resolved = TRUE;
- cfmt->custom_field = NULL;
- cfmt->custom_occurrence = 0;
- prefs.col_list = g_list_append(prefs.col_list, cfmt);
- }
- prefs.num_cols = DEF_NUM_COLS;
+ if (prefs.col_list) {
+ free_col_info(prefs.col_list);
+ prefs.col_list = NULL;
+ }
+ for (i = 0; i < DEF_NUM_COLS; i++) {
+ cfmt = g_new(fmt_data,1);
+ cfmt->title = g_strdup(col_fmt[i * 2]);
+ parse_column_format(cfmt, col_fmt[(i * 2) + 1]);
+ cfmt->visible = TRUE;
+ cfmt->resolved = TRUE;
+ cfmt->custom_field = NULL;
+ cfmt->custom_occurrence = 0;
+ prefs.col_list = g_list_append(prefs.col_list, cfmt);
}
+ prefs.num_cols = DEF_NUM_COLS;
/* set the default values for the capture dialog box */
prefs.capture_prom_mode = TRUE;
diff --git a/ui/qt/wireshark_application.cpp b/ui/qt/wireshark_application.cpp
index 1a516a02fe..4411e35d16 100644
--- a/ui/qt/wireshark_application.cpp
+++ b/ui/qt/wireshark_application.cpp
@@ -363,8 +363,8 @@ void WiresharkApplication::setConfigurationProfile(const gchar *profile_name)
prefs_to_capture_opts();
prefs_apply_all();
- emit preferencesChanged();
emit columnsChanged();
+ emit preferencesChanged();
emit recentFilesRead();
emit filterExpressionsChanged();
// macros_post_update();