From a9a8c3a3848ef0e4a78c5b7c0b8bb9dce849c3cc Mon Sep 17 00:00:00 2001 From: Federico Mena Quintero Date: Sat, 25 Nov 2000 07:31:24 +0000 Subject: Plug leaks of the fullname and fulldefaultname. 2000-11-25 Federico Mena Quintero * e-setup.c (check_dir_recur): Plug leaks of the fullname and fulldefaultname. (check_evolution_directory): Plug leaks of defaultdir and newfiles and the list's data; made the code have a single return point. * e-shell.c (e_shell_restore_from_settings): Plug leak of prefix. (corba_class_init): Plug leak; we were not assigning the vepv->_base_epv. * evolution-storage.c (corba_class_init): Likewise. * evolution-local-storage.c (corba_class_init): Likewise. svn path=/trunk/; revision=6667 --- shell/e-setup.c | 68 ++++++++++++++++++++++++++++++--------------------------- 1 file changed, 36 insertions(+), 32 deletions(-) (limited to 'shell/e-setup.c') diff --git a/shell/e-setup.c b/shell/e-setup.c index ee39f0d398..d9fc75f1dd 100644 --- a/shell/e-setup.c +++ b/shell/e-setup.c @@ -46,7 +46,7 @@ check_dir_recur (const char *evolution_directory, DIR *def; GList *newfiles = NULL; struct dirent *current; - + def = opendir (current_directory); if (def == NULL) return NULL; @@ -55,22 +55,22 @@ check_dir_recur (const char *evolution_directory, while (current != NULL) { struct stat buf; char *fullname, *fulldefaultname; - - fullname = g_concat_dir_and_file (evolution_directory, - current->d_name); - fulldefaultname = g_concat_dir_and_file (current_directory, - current->d_name); - if (current->d_name[0] == '.' && - (current->d_name[1] == '\0' || + if (current->d_name[0] == '.' && + (current->d_name[1] == '\0' || (current->d_name[1] == '.' && current->d_name[2] == '\0'))) { current = readdir (def); continue; } + fullname = g_concat_dir_and_file (evolution_directory, + current->d_name); + fulldefaultname = g_concat_dir_and_file (current_directory, + current->d_name); + if (stat (fullname, &buf) == -1) { char *name; - + name = g_strdup (fulldefaultname); newfiles = g_list_append (newfiles, name); } else { @@ -80,7 +80,7 @@ check_dir_recur (const char *evolution_directory, fulldefaultname)); } } - + g_free (fulldefaultname); g_free (fullname); current = readdir (def); @@ -103,27 +103,31 @@ check_evolution_directory (const char *evolution_directory) defaultdir = g_strdup (EVOLUTION_DATADIR "/evolution/default_user"); newfiles = g_list_concat (NULL, check_dir_recur (evolution_directory, defaultdir)); - - if (newfiles == NULL) - return TRUE; + + if (newfiles == NULL) { + retval = TRUE; + goto out; + } dialog = gnome_dialog_new (_("Evolution installation"), GNOME_STOCK_BUTTON_OK, GNOME_STOCK_BUTTON_CANCEL, NULL); - + label1 = gtk_label_new (_("This new version of Evolution needs to install additional files\ninto your personal Evolution directory")); label2 = gtk_label_new (_("Please click \"OK\" to install the files, or \"Cancel\" to exit.")); - + gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dialog)->vbox), label1, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dialog)->vbox), label2, TRUE, TRUE, 0); - + gtk_widget_show (label1); gtk_widget_show (label2); result = gnome_dialog_run_and_close (GNOME_DIALOG (dialog)); - if (result != 0) - return FALSE; + if (result != 0) { + retval = FALSE; + goto out; + } retval = TRUE; for (l = newfiles; l; l = l->next) { @@ -136,34 +140,34 @@ check_evolution_directory (const char *evolution_directory) evolution_directory, "/", shortpath, NULL); - + if (system (command) != 0) { retval = FALSE; } else { retval = (retval && TRUE); } - + g_free (command); - - g_free (l->data); } - g_list_free (newfiles); - g_free (defaultdir); - - if (retval == FALSE) { + if (retval == FALSE) e_notice (NULL, GNOME_MESSAGE_BOX_ERROR, _("Could not update files correctly")); - return FALSE; - } else { + else e_notice (NULL, GNOME_MESSAGE_BOX_INFO, _("Evolution files successfully installed.")); - return TRUE; - } - return TRUE; + out: + + for (l = newfiles; l; l = l->next) + g_free (l->data); + + g_list_free (newfiles); + g_free (defaultdir); + + return retval; } - + static gboolean copy_default_stuff (const char *evolution_directory) -- cgit v1.2.3