Fix a few more memleaks found by valgrind (all deriving

from the get_persconffile_path mess).

svn path=/trunk/; revision=5927
This commit is contained in:
Jörg Mayer 2002-08-01 03:15:29 +00:00
parent db0d014224
commit 9630bf353e
6 changed files with 25 additions and 14 deletions

View File

@ -93,6 +93,7 @@ Joerg Mayer <jmayer[AT]loplof.de> {
Clean up #includes
Mark last packet of TFTP transfer as such in the Info column
Dissect both the BOOTP server and client ports as bootp/DHCP
Fix some small memleaks found by valgrind
}
Martin Maciaszek <fastjack[AT]i-s-o.net> {

View File

@ -1,6 +1,6 @@
/* main.c
*
* $Id: main.c,v 1.255 2002/07/07 22:14:03 guy Exp $
* $Id: main.c,v 1.256 2002/08/01 03:15:29 jmayer Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -1213,7 +1213,7 @@ main(int argc, char *argv[])
#endif
char *gpf_path, *cf_path, *df_path;
const char *pf_path;
char *pf_path;
int gpf_open_errno, pf_open_errno, cf_open_errno, df_open_errno;
int err;
#ifdef HAVE_LIBPCAP
@ -1953,6 +1953,8 @@ main(int argc, char *argv[])
simple_dialog(ESD_TYPE_WARN, NULL,
"Could not open your preferences file\n\"%s\": %s.", pf_path,
strerror(pf_open_errno));
g_free(pf_path);
pf_path = NULL;
}
/* If the user's capture filter file exists but we failed to open it,
@ -2060,6 +2062,9 @@ main(int argc, char *argv[])
if (prefs_write_needed) {
write_prefs(&pf_path);
}
} else {
/* Ignore errors silently */
g_free(pf_path);
}
epan_cleanup();

View File

@ -1,7 +1,7 @@
/* prefs_dlg.c
* Routines for handling preferences
*
* $Id: prefs_dlg.c,v 1.49 2002/07/17 00:22:30 guy Exp $
* $Id: prefs_dlg.c,v 1.50 2002/08/01 03:15:29 jmayer Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -914,7 +914,7 @@ prefs_main_save_cb(GtkWidget *save_bt _U_, gpointer parent_w)
gboolean must_redissect = FALSE;
int err;
char *pf_dir_path;
const char *pf_path;
char *pf_path;
/* Fetch the preferences (i.e., make sure all the values set in all of
the preferences panes have been copied to "prefs" and the registered
@ -950,6 +950,7 @@ prefs_main_save_cb(GtkWidget *save_bt _U_, gpointer parent_w)
simple_dialog(ESD_TYPE_WARN, NULL,
"Can't open preferences file\n\"%s\": %s.", pf_path,
strerror(err));
g_free(pf_path);
}
}

12
prefs.c
View File

@ -1,7 +1,7 @@
/* prefs.c
* Routines for handling preferences
*
* $Id: prefs.c,v 1.86 2002/06/16 00:58:37 guy Exp $
* $Id: prefs.c,v 1.87 2002/08/01 03:15:25 jmayer Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -721,10 +721,10 @@ static void read_prefs_file(const char *pf_path, FILE *pf);
return NULL. */
e_prefs *
read_prefs(int *gpf_errno_return, char **gpf_path_return,
int *pf_errno_return, const char **pf_path_return)
int *pf_errno_return, char **pf_path_return)
{
int i;
const char *pf_path;
char *pf_path;
FILE *pf;
fmt_data *cfmt;
gchar *col_fmt[] = {"No.", "%m", "Time", "%t",
@ -876,6 +876,8 @@ read_prefs(int *gpf_errno_return, char **gpf_path_return,
/* We succeeded in opening it; read it. */
read_prefs_file(pf_path, pf);
fclose(pf);
g_free(pf_path);
pf_path = NULL;
} else {
/* We failed to open it. If we failed for some reason other than
"it doesn't exist", return the errno and the pathname, so our
@ -1662,9 +1664,9 @@ write_module_prefs(gpointer data, gpointer user_data)
If we got an error, stuff a pointer to the path of the preferences file
into "*pf_path_return", and return the errno. */
int
write_prefs(const char **pf_path_return)
write_prefs(char **pf_path_return)
{
const char *pf_path;
char *pf_path;
FILE *pf;
GList *clp, *col_l;
fmt_data *cfmt;

View File

@ -1,7 +1,7 @@
/* prefs.h
* Definitions for preference handling routines
*
* $Id: prefs.h,v 1.38 2002/05/11 18:58:02 guy Exp $
* $Id: prefs.h,v 1.39 2002/08/01 03:15:25 jmayer Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -202,13 +202,13 @@ extern void prefs_register_modules(void);
the user's preferences file, stuff the errno into "*pf_errno_return"
and a pointer to the path of the file into "*pf_path_return", and
return NULL. */
extern e_prefs *read_prefs(int *, char **, int *, const char **);
extern e_prefs *read_prefs(int *, char **, int *, char **);
/* Write out "prefs" to the user's preferences file, and return 0.
If we got an error, stuff a pointer to the path of the preferences file
into "*pf_path_return", and return the errno. */
extern int write_prefs(const char **);
extern int write_prefs(char **);
/* Copy a set of preferences. */
extern void copy_prefs(e_prefs *dest, e_prefs *src);

View File

@ -1,6 +1,6 @@
/* tethereal.c
*
* $Id: tethereal.c,v 1.149 2002/07/17 00:22:12 guy Exp $
* $Id: tethereal.c,v 1.150 2002/08/01 03:15:26 jmayer Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -313,7 +313,7 @@ main(int argc, char *argv[])
#endif
char *gpf_path;
const char *pf_path;
char *pf_path;
int gpf_open_errno, pf_open_errno;
int err;
#ifdef HAVE_LIBPCAP
@ -377,6 +377,8 @@ main(int argc, char *argv[])
if (pf_path != NULL) {
fprintf(stderr, "Can't open your preferences file \"%s\": %s.\n", pf_path,
strerror(pf_open_errno));
g_free(pf_path);
pf_path = NULL;
}
/* Set the name resolution code's flags from the preferences. */