diff options
author | Stig Bjørlykke <stig@bjorlykke.org> | 2015-11-19 19:54:41 +0100 |
---|---|---|
committer | Stig Bjørlykke <stig@bjorlykke.org> | 2015-11-20 07:57:25 +0000 |
commit | 0ae19656e12089271ea5941bcb4663bedc337b69 (patch) | |
tree | f7fe02922d7b58f389acdf84cbb0bac50cbd7a9f /epan/prefs.c | |
parent | c297df134b4ba7afc84272a8c425a852e4b5408a (diff) |
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>
Diffstat (limited to 'epan/prefs.c')
-rw-r--r-- | epan/prefs.c | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/epan/prefs.c b/epan/prefs.c index 36cd4ebd7a..a1b4072b0e 100644 --- a/epan/prefs.c +++ b/epan/prefs.c @@ -3036,20 +3036,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; |