Commit 9819635a authored by Brian Cameron's avatar Brian Cameron Committed by Brian Cameron

Correct memory leaks. Fixes bug #315388, patch by Ray Strode with minor

2005-09-06  Brian Cameron <Brian.Cameron@sun.com>

        * daemon/auth.c, daemon/gdm.c, daemon/slave.c,
          daemon/verify-pam.c, gui/gdmchooser.c, gui/gdmcomm.c,
          gui/gdmdynamic.c, gui/gdmlogin.c, gui/gdmphotosetup.c,
          gui/gdmsetup.c, gui/greeter/greeter.c,
          gui/greeter/greeter_canvas_item.c,
          gui/greeter/greeter_session.c,
          gui/modules/keymouselistener.c,
          utils/gdm-dmx-reconnect-proxy.c,
          vicious-extensions/vc-misc.c:  Correct memory leaks.
          Fixes bug #315388, patch by Ray Strode with minor
          tweaks by myself.
parent 42a1e22c
2005-09-06 Brian Cameron <Brian.Cameron@sun.com>
* daemon/auth.c, daemon/gdm.c, daemon/slave.c,
daemon/verify-pam.c, gui/gdmchooser.c, gui/gdmcomm.c,
gui/gdmdynamic.c, gui/gdmlogin.c, gui/gdmphotosetup.c,
gui/gdmsetup.c, gui/greeter/greeter.c,
gui/greeter/greeter_canvas_item.c,
gui/greeter/greeter_session.c,
gui/modules/keymouselistener.c,
utils/gdm-dmx-reconnect-proxy.c,
vicious-extensions/vc-misc.c: Correct memory leaks.
Fixes bug #315388, patch by Ray Strode with minor
tweaks by myself.
* gui/gdmphotosetup.c: Corrected definition of void
function to avoid compiler warning.
......
......@@ -581,6 +581,18 @@ gdm_auth_user_add (GdmDisplay *d, uid_t user, const char *homedir)
if (!d)
return FALSE;
if (d->local_auths != NULL) {
gdm_auth_free_auth_list (d->local_auths);
d->local_auths = NULL;
}
d->local_auths = get_local_auths (d);
if (d->local_auths == NULL) {
gdm_error ("Can't make cookies");
return FALSE;
}
gdm_debug ("gdm_auth_user_add: Adding cookie for %d", user);
/* Determine whether UserAuthDir is specified. Otherwise ~user is used */
......@@ -597,18 +609,6 @@ gdm_auth_user_add (GdmDisplay *d, uid_t user, const char *homedir)
authdir = g_strdup (homedir);
}
if (d->local_auths != NULL) {
gdm_auth_free_auth_list (d->local_auths);
d->local_auths = NULL;
}
d->local_auths = get_local_auths (d);
if (d->local_auths == NULL) {
gdm_error ("Can't make cookies");
return FALSE;
}
try_user_add_again:
locked = FALSE;
......@@ -712,6 +712,8 @@ try_user_add_again:
af = gdm_safe_fopen_ap (d->userauth);
}
g_free (authdir);
if G_UNLIKELY (af == NULL) {
/* Really no need to clean up here - this process is a goner anyway */
gdm_error (_("%s: Could not open cookie file %s"),
......@@ -729,8 +731,6 @@ try_user_add_again:
goto try_user_add_again;
}
g_free (authdir);
return FALSE;
}
......@@ -788,8 +788,6 @@ try_user_add_again:
gdm_debug ("gdm_auth_user_add: Done");
umask (022);
g_free (authdir);
return ret;
}
......
......@@ -323,6 +323,7 @@ check_servauthdir (struct stat *statbuf)
if (GdmConsoleNotify)
gdm_text_message_dialog (s);
GdmPidFile = NULL;
g_free (s);
gdm_fail (_("%s: Authdir %s does not exist. Aborting."), "gdm_config_parse", GdmServAuthDir);
}
......@@ -336,6 +337,7 @@ check_servauthdir (struct stat *statbuf)
if (GdmConsoleNotify)
gdm_text_message_dialog (s);
GdmPidFile = NULL;
g_free (s);
gdm_fail (_("%s: Authdir %s is not a directory. Aborting."), "gdm_config_parse", GdmServAuthDir);
}
}
......@@ -789,6 +791,7 @@ gdm_config_parse (void)
"and restart GDM.")));
gdm_text_message_dialog (s);
GdmPidFile = NULL;
g_free (s);
gdm_fail (_("%s: XDMCP disabled and no static servers defined. Aborting!"), "gdm_config_parse");
}
}
......@@ -813,6 +816,7 @@ gdm_config_parse (void)
if (GdmConsoleNotify)
gdm_text_message_dialog (s);
GdmPidFile = NULL;
g_free (s);
gdm_fail (_("%s: Can't find the GDM user '%s'. Aborting!"), "gdm_config_parse", GdmUser);
} else {
GdmUserId = pwent->pw_uid;
......@@ -828,6 +832,7 @@ gdm_config_parse (void)
if (GdmConsoleNotify)
gdm_text_message_dialog (s);
GdmPidFile = NULL;
g_free (s);
gdm_fail (_("%s: The GDM user should not be root. Aborting!"), "gdm_config_parse");
}
......@@ -842,6 +847,7 @@ gdm_config_parse (void)
if (GdmConsoleNotify)
gdm_text_message_dialog (s);
GdmPidFile = NULL;
g_free (s);
gdm_fail (_("%s: Can't find the GDM group '%s'. Aborting!"), "gdm_config_parse", GdmGroup);
} else {
GdmGroupId = grent->gr_gid;
......@@ -857,6 +863,7 @@ gdm_config_parse (void)
if (GdmConsoleNotify)
gdm_text_message_dialog (s);
GdmPidFile = NULL;
g_free (s);
gdm_fail (_("%s: The GDM group should not be root. Aborting!"), "gdm_config_parse");
}
......@@ -935,6 +942,7 @@ gdm_config_parse (void)
if (GdmConsoleNotify)
gdm_text_message_dialog (s);
GdmPidFile = NULL;
g_free (s);
gdm_fail (_("%s: Authdir %s is not owned by user %s, group %s. Aborting."), "gdm_config_parse",
GdmServAuthDir, gdm_root_user (), GdmGroup);
}
......@@ -952,6 +960,7 @@ gdm_config_parse (void)
if (GdmConsoleNotify)
gdm_text_message_dialog (s);
GdmPidFile = NULL;
g_free (s);
gdm_fail (_("%s: Authdir %s has wrong permissions %o. Should be %o. Aborting."), "gdm_config_parse",
GdmServAuthDir, statbuf.st_mode, (S_IRWXU|S_IRWXG|S_ISVTX));
}
......
......@@ -1206,16 +1206,20 @@ gdm_slave_check_user_wants_to_log_in (const char *user)
if (d->type != TYPE_XDMCP_PROXY) {
int r;
if (!GdmDoubleLoginWarning)
if (!GdmDoubleLoginWarning) {
g_free (migrate_to);
return TRUE;
}
if (GdmAlwaysLoginCurrentSession)
r = 1;
else
r = ask_migrate (migrate_to);
if (r <= 0)
if (r <= 0) {
g_free (migrate_to);
return TRUE;
}
if (migrate_to == NULL ||
(migrate_to != NULL && r == 2)) {
......@@ -2338,15 +2342,17 @@ get_facefile_from_global (const char *username,
picfile = g_build_filename (GdmGlobalFaceDir,
username, NULL);
if (check_global_file (picfile, uid))
if (check_global_file (picfile, uid))
return picfile;
g_free (picfile);
picfile = gdm_make_filename (GdmGlobalFaceDir,
username, ".png");
if (check_global_file (picfile, uid))
if (check_global_file (picfile, uid))
return picfile;
g_free (picfile);
return NULL;
}
......@@ -3512,6 +3518,7 @@ wipe_xsession_errors (struct passwd *pwent,
VE_IGNORE_EINTR (ent = readdir (dir));
}
VE_IGNORE_EINTR (closedir (dir));
g_free (prefix);
}
NEVER_FAILS_root_set_euid_egid (old, oldg);
......@@ -3733,6 +3740,7 @@ session_child_run (struct passwd *pwent,
language, _("System default"));
gdm_error_box (d, GTK_MESSAGE_ERROR, msg);
language = NULL;
g_free (msg);
}
/* Now still as root make the system authfile not readable by others,
......@@ -4231,6 +4239,7 @@ gdm_slave_session_start (void)
gdm_debug ("User canceled login");
gdm_verify_cleanup (d);
session_started = FALSE;
g_free (usrlang);
return;
}
......@@ -4240,6 +4249,7 @@ gdm_slave_session_start (void)
gdm_debug ("User canceled login");
gdm_verify_cleanup (d);
session_started = FALSE;
g_free (usrlang);
return;
}
} else {
......
......@@ -488,17 +488,17 @@ gdm_verify_pam_conv (int num_msg, const struct pam_message **msg,
if (pamh == NULL)
return PAM_CONV_ERR;
reply = malloc (sizeof (struct pam_response) * num_msg);
if (reply == NULL)
return PAM_CONV_ERR;
/* Should never happen unless PAM is on crack and keeps asking questions
after we told it to go away. So tell it to go away again and
maybe it will listen */
if ( ! gdm_slave_action_pending ())
return PAM_CONV_ERR;
reply = malloc (sizeof (struct pam_response) * num_msg);
if (reply == NULL)
return PAM_CONV_ERR;
memset (reply, 0, sizeof (struct pam_response) * num_msg);
/* Here we set the login if it wasn't already set,
......
......@@ -1341,11 +1341,13 @@ gdm_chooser_add_host (void)
qa6 = g_new0 (struct sockaddr_in6, 1);
qa6->sin6_family = AF_INET6;
if (have_ipv6 && strlen (name) == 32 && from_hex (name, (char *) &qa6->sin6_addr, strlen (name)) == 0) ;
if (have_ipv6 && strlen (name) == 32 &&
from_hex (name, (char *) &qa6->sin6_addr, strlen (name)) == 0) ;
else
#endif
if (strlen (name) == 8 && from_hex (name, (char *) &qa->sin_addr, strlen (name)) == 0) {
if (strlen (name) == 8 &&
from_hex (name, (char *) &qa->sin_addr, strlen (name)) == 0) {
#ifdef ENABLE_IPV6
if (have_ipv6) {
char tmpaddr[30];
......@@ -1380,42 +1382,49 @@ gdm_chooser_add_host (void)
if (have_ipv6) {
char tmpaddr [30];
sprintf (tmpaddr, "::ffff:%s", inet_ntoa(((struct sockaddr_in *)result->ai_addr)->sin_addr));
sprintf (tmpaddr, "::ffff:%s",
inet_ntoa(((struct sockaddr_in *)result->ai_addr)->sin_addr));
inet_pton (AF_INET6, tmpaddr, &qa6->sin6_addr);
}
}
}
else
#endif
if ((hostent = gethostbyname (name)) != NULL && hostent->h_addrtype == AF_INET && hostent->h_length == 4) {
memmove (&qa->sin_addr, hostent->h_addr, 4);
if ((hostent = gethostbyname (name)) != NULL &&
hostent->h_addrtype == AF_INET && hostent->h_length == 4) {
memmove (&qa->sin_addr, hostent->h_addr, 4);
} else {
GtkWidget *dialog;
gchar *msg;
msg = g_strdup_printf (_("Cannot find the host \"%s\". "
"Perhaps you have mistyped it."),
name);
dialog = ve_hig_dialog_new
(GTK_WINDOW (chooser) /* parent */,
GTK_DIALOG_MODAL /* flags */,
GTK_MESSAGE_ERROR,
GTK_BUTTONS_OK,
_("Cannot find host"),
msg);
g_free (msg);
if (RUNNING_UNDER_GDM)
gdm_wm_center_window (GTK_WINDOW (dialog));
gdm_wm_no_login_focus_push ();
gtk_dialog_run (GTK_DIALOG (dialog));
gtk_widget_destroy (dialog);
gdm_wm_no_login_focus_pop ();
return; /* not a valid address */
}
GtkWidget *dialog;
gchar *msg;
msg = g_strdup_printf (_("Cannot find the host \"%s\". "
"Perhaps you have mistyped it."),
name);
dialog = ve_hig_dialog_new
(GTK_WINDOW (chooser) /* parent */,
GTK_DIALOG_MODAL /* flags */,
GTK_MESSAGE_ERROR,
GTK_BUTTONS_OK,
_("Cannot find host"),
msg);
g_free (msg);
if (RUNNING_UNDER_GDM)
gdm_wm_center_window (GTK_WINDOW (dialog));
gdm_wm_no_login_focus_push ();
gtk_dialog_run (GTK_DIALOG (dialog));
gtk_widget_destroy (dialog);
gdm_wm_no_login_focus_pop ();
g_free (qa);
#ifdef ENABLE_IPV6
g_free (qa6);
#endif
return; /* not a valid address */
}
#ifdef ENABLE_IPV6
if (have_ipv6) {
memset (&sock6, 0, sizeof (struct sockaddr_in6));
......@@ -1484,6 +1493,10 @@ gdm_chooser_add_host (void)
/* empty the text entry to indicate success */
gtk_entry_set_text (GTK_ENTRY (add_entry), "");
g_free (qa);
#ifdef ENABLE_IPV6
g_free (qa6);
#endif
return;
}
#ifdef ENABLE_IPV6
......@@ -1514,11 +1527,9 @@ gdm_chooser_add_host (void)
/* empty the text entry to indicate success */
gtk_entry_set_text (GTK_ENTRY (add_entry), "");
if (have_ipv6)
g_free (qa);
g_free (qa);
#ifdef ENABLE_IPV6
else
g_free (qa6);
g_free (qa6);
#endif
}
......@@ -1577,6 +1588,7 @@ gdm_chooser_abort (const gchar *format, ...)
syslog (LOG_ERR, "%s", s);
closelog ();
g_free (s);
exit (EXIT_FAILURE);
}
......@@ -1593,6 +1605,7 @@ gdm_chooser_warn (const gchar *format, ...)
syslog (LOG_ERR, "%s", s);
closelog ();
g_free (s);
}
......
......@@ -352,6 +352,7 @@ gdmcomm_get_auth_cookie (void)
cmd = g_strdup_printf (GDM_SUP_AUTH_LOCAL " %s", buffer);
ret = gdmcomm_call_gdm (cmd, NULL /* auth cookie */, "2.2.4.0", 5);
g_free (cmd);
if (ret != NULL &&
strcmp (ret, "OK") == 0) {
g_free (ret);
......
......@@ -169,6 +169,7 @@ main (int argc, char *argv[])
cookie = g_strdup(buf);
VE_IGNORE_EINTR (fclose (fp));
}
g_free (filename);
}
ret = gdmcomm_call_gdm (cstr, cookie, version, 5);
......
......@@ -1734,8 +1734,10 @@ theme_allowed (const char *theme)
return TRUE;
for (i = 0; vec[i] != NULL; i++) {
if (strcmp (vec[i], theme) == 0)
if (strcmp (vec[i], theme) == 0) {
g_strfreev (vec);
return TRUE;
}
}
g_strfreev (vec);
......
......@@ -378,8 +378,10 @@ fill_model (GtkTreeModel *model)
path = g_build_filename (facedir, filename, NULL);
pixbuf = gdk_pixbuf_new_from_file (path, NULL);
if (! pixbuf)
if (! pixbuf) {
g_free (path);
continue;
}
gtk_list_store_prepend (store, &iter);
......
......@@ -337,6 +337,7 @@ xservers_get_servers (GtkListStore *store)
int vt = atoi(key);
key = g_strconcat(GDM_KEY_SECTION_SERVERS, "/", key, NULL);
cpy = ve_config_get_string (cfg, key);
g_free (key);
server = ve_first_word (cpy);
options = ve_rest (cpy);
......
......@@ -1113,6 +1113,7 @@ get_theme_file (const char *in, char **theme_dir)
}
config = ve_config_new (info);
g_free (info);
s = ve_config_get_translated_string (config, "GdmGreeterTheme/Greeter");
if (s == NULL || s[0] == '\0')
......
......@@ -565,8 +565,12 @@ greeter_canvas_item_break_set_string (GreeterItemInfo *info,
gnome_canvas_item_set (GNOME_CANVAS_ITEM (canvas_item), textattr, orig, NULL);
pango_layout_get_pixel_size (GNOME_CANVAS_TEXT (canvas_item)->layout, width, height);
if (real_item != canvas_item)
if (real_item != canvas_item) {
gtk_object_destroy (GTK_OBJECT (canvas_item));
g_string_free (line, TRUE);
g_string_free (word, TRUE);
g_string_free (str, TRUE);
}
return;
}
......@@ -579,8 +583,12 @@ greeter_canvas_item_break_set_string (GreeterItemInfo *info,
*width = lwidth;
if (height != NULL)
*height = lheight;
if (real_item != canvas_item)
if (real_item != canvas_item) {
gtk_object_destroy (GTK_OBJECT (canvas_item));
g_string_free (line, TRUE);
g_string_free (word, TRUE);
g_string_free (str, TRUE);
}
return;
}
......
......@@ -116,6 +116,7 @@ greeter_session_lookup (const char *saved_session)
gchar *firstmsg;
gchar *secondmsg;
g_free (session);
session = g_strdup (default_session);
firstmsg = g_strdup_printf (_("Do you wish to make %s the default for "
"future sessions?"),
......
......@@ -174,7 +174,7 @@ init_xinput (GdkDisplay *display, GdkWindow *root)
device = XOpenDevice (GDK_DISPLAY_XDISPLAY (display),
devices[i].id);
for (j=0; j < device->num_classes && number < 40; j++) {
for (j=0; j < device->num_classes && number < 39; j++) {
switch (device->classes[j].input_class)
{
......
......@@ -99,6 +99,7 @@ main (int argc, char **argv)
options_context = g_option_context_new (_("- migrate a backend display from one DMX display to another"));
g_option_context_add_main_entries (options_context, options, GETTEXT_PACKAGE);
g_option_context_parse (options_context, &argc, &argv, NULL);
g_option_context_free (options_context);
if (to_display == NULL) {
g_printerr (_("You must specify a destination DMX display using %s\n"), "--to");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment