From 9ff02af06c034b98e085b4d8aa445984bdf03c84 Mon Sep 17 00:00:00 2001 From: Jens Granseuer Date: Mon, 26 Feb 2007 17:05:09 +0000 Subject: [PATCH] prevent the child watcher from accessing already released memory after the 2007-02-26 Jens Granseuer * gnome-about-me-password.c: (stop_passwd), (child_watch_remove), (free_passwd_resources): prevent the child watcher from accessing already released memory after the dialog has been closed (should fix bug #411697) * gnome-about-me-password.c: (gnome_about_me_password): unref dialog when we're done * gnome-about-me.c: (about_me_setup_dialog): remove redundant warning svn path=/trunk/; revision=7338 --- capplets/about-me/ChangeLog | 11 +++++++ capplets/about-me/gnome-about-me-password.c | 32 +++++++++++++++------ capplets/about-me/gnome-about-me.c | 1 - 3 files changed, 34 insertions(+), 10 deletions(-) diff --git a/capplets/about-me/ChangeLog b/capplets/about-me/ChangeLog index 2c919edd1..0a730917e 100644 --- a/capplets/about-me/ChangeLog +++ b/capplets/about-me/ChangeLog @@ -1,3 +1,14 @@ +2007-02-26 Jens Granseuer + + * gnome-about-me-password.c: (stop_passwd), (child_watch_remove), + (free_passwd_resources): prevent the child watcher from accessing + already released memory after the dialog has been closed (should fix + bug #411697) + + * gnome-about-me-password.c: (gnome_about_me_password): unref dialog + when we're done + * gnome-about-me.c: (about_me_setup_dialog): remove redundant warning + 2007-02-25 Jens Granseuer Patch by: Diego Escalante Urrelo diff --git a/capplets/about-me/gnome-about-me-password.c b/capplets/about-me/gnome-about-me-password.c index 1c77941c9..ec48d1d31 100644 --- a/capplets/about-me/gnome-about-me-password.c +++ b/capplets/about-me/gnome-about-me-password.c @@ -134,6 +134,9 @@ enum { static void stop_passwd (PasswordDialog *pdialog); +static void +child_watch_remove (PasswordDialog *pdialog); + static void free_passwd_resources (PasswordDialog *pdialog); @@ -270,18 +273,34 @@ stop_passwd (PasswordDialog *pdialog) * If we return this way we can safely kill passwd as it has completed * its task. * - * Maybe we should run free_passwd_resources here first, and not let - * our child watcher do it? + * We must run free_passwd_resources here and not let our child + * watcher do it, since it will access invalid memory after the + * dialog has been closed and cleaned up. */ if (pdialog->backend_pid != -1) { + child_watch_remove (pdialog); kill (pdialog->backend_pid, 9); + free_passwd_resources (pdialog); } /* Our child_watch_cb should now handle our kill signal, * run waitpid and call free_passwd_resources appropriately. */ } +/* Remove the child watcher only */ +static void +child_watch_remove (PasswordDialog *pdialog) +{ + /* Remove IO watcher */ + if (pdialog->backend_stdout_watch_id != 0) { + + g_source_remove (pdialog->backend_stdout_watch_id); + + pdialog->backend_stdout_watch_id = 0; + } +} + /* Clean up passwd resources */ static void free_passwd_resources (PasswordDialog *pdialog) @@ -315,13 +334,7 @@ free_passwd_resources (PasswordDialog *pdialog) pdialog->backend_stdout = NULL; } - /* Remove IO watcher */ - if (pdialog->backend_stdout_watch_id != 0) { - - g_source_remove (pdialog->backend_stdout_watch_id); - - pdialog->backend_stdout_watch_id = 0; - } + child_watch_remove (pdialog); /* Close PID */ if (pdialog->backend_pid != -1) { @@ -1093,5 +1106,6 @@ gnome_about_me_password (GtkWindow *parent) stop_passwd (pdialog); gtk_widget_destroy (wpassdlg); g_queue_free (pdialog->backend_stdin_queue); + g_object_unref (dialog); g_free (pdialog); } diff --git a/capplets/about-me/gnome-about-me.c b/capplets/about-me/gnome-about-me.c index a0101d079..30504991d 100644 --- a/capplets/about-me/gnome-about-me.c +++ b/capplets/about-me/gnome-about-me.c @@ -754,7 +754,6 @@ about_me_setup_dialog (void) "about-me-dialog", NULL); if (dialog == NULL) { - g_warning ("Unable to load glade file."); about_me_destroy (me); return -1; }