diff options
author | stig <stig@f5534014-38df-0310-8fa8-9805f1628bb7> | 2008-01-15 21:41:52 +0000 |
---|---|---|
committer | stig <stig@f5534014-38df-0310-8fa8-9805f1628bb7> | 2008-01-15 21:41:52 +0000 |
commit | e31282a19ec1d1e031bd149652101c49abdb5d7e (patch) | |
tree | a9ae2c65e914f80d9d2ff09f2f5b39e408d87025 /disabled_protos.c | |
parent | 25d1474ade8b24b7e1250c7e150615b2db85b30e (diff) |
Discard existing list of disabled protocols in read_disabled_protos_list()
even if disabled_protos file does not exist. This fixes a problem with
disabled protocols when changing profile.
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@24102 f5534014-38df-0310-8fa8-9805f1628bb7
Diffstat (limited to 'disabled_protos.c')
-rw-r--r-- | disabled_protos.c | 38 |
1 files changed, 25 insertions, 13 deletions
diff --git a/disabled_protos.c b/disabled_protos.c index 7fd7775b5a..bd1679ff26 100644 --- a/disabled_protos.c +++ b/disabled_protos.c @@ -54,6 +54,25 @@ static GList *disabled_protos = NULL; #define INIT_BUF_SIZE 128 +static void +discard_existing_list (GList **flp) +{ + GList *fl_ent; + protocol_def *prot; + + if (*flp != NULL) { + fl_ent = g_list_first(*flp); + while (fl_ent != NULL) { + prot = (protocol_def *) fl_ent->data; + g_free(prot->name); + g_free(prot); + fl_ent = fl_ent->next; + } + g_list_free(*flp); + *flp = NULL; + } +} + /* * Read in a list of disabled protocols. * @@ -80,6 +99,9 @@ read_disabled_protos_list(char **gpath_return, int *gopen_errno_return, /* Construct the pathname of the global disabled protocols file. */ gff_path = get_datafile_path(GLOBAL_PROTOCOLS_FILE_NAME); + /* If we already have a list of protocols, discard it. */ + discard_existing_list (&global_disabled_protos); + /* Read the global disabled protocols file, if it exists. */ *gpath_return = NULL; if ((ff = eth_fopen(gff_path, "r")) != NULL) { @@ -110,6 +132,9 @@ read_disabled_protos_list(char **gpath_return, int *gopen_errno_return, /* Construct the pathname of the user's disabled protocols file. */ ff_path = get_persconffile_path(PROTOCOLS_FILE_NAME, TRUE, FALSE); + /* If we already have a list of protocols, discard it. */ + discard_existing_list (&disabled_protos); + /* Read the user's disabled protocols file, if it exists. */ *path_return = NULL; if ((ff = eth_fopen(ff_path, "r")) != NULL) { @@ -141,7 +166,6 @@ static int read_disabled_protos_list_file(const char *ff_path, FILE *ff, GList **flp) { - GList *fl_ent; protocol_def *prot; int c; char *prot_name; @@ -149,18 +173,6 @@ read_disabled_protos_list_file(const char *ff_path, FILE *ff, int prot_name_index; int line = 1; - /* If we already have a list of protocols, discard it. */ - if (*flp != NULL) { - fl_ent = g_list_first(*flp); - while (fl_ent != NULL) { - prot = (protocol_def *) fl_ent->data; - g_free(prot->name); - g_free(prot); - fl_ent = fl_ent->next; - } - g_list_free(*flp); - *flp = NULL; - } /* Allocate the protocol name buffer. */ prot_name_len = INIT_BUF_SIZE; |