From 7c8e5faa79df1ea5cf3c7d8ddf7ffa4984fc0cb6 Mon Sep 17 00:00:00 2001 From: Eygene Ryabinkin Date: Wed, 29 Apr 2009 00:22:46 +0400 Subject: [PATCH] session-client: fix multiple SEGVs 1. Don't call SmcCloseConnection if no connection is present. 2. Make copy of {clone | resign | restart | discard |shutdown}_command to make the caller to manage the passed argument arrays by himself and to provide us with the copy of arguments that we can use and free afterwards. Without deep copy things choke at client_session_free because some static strings were passed inside 'clone_command' and g_strfreev() had tried to free() them. I had seen these two problems when I was tried to start xfce4 settings-helper without running session manager: it whined that ----- (xfce4-settings-helper:86452): xfce4-settings-helper-WARNING **: Failed to connect to session manager ----- and dumped core afterwards. With this patch I can run the utility without session manager. May be the other clients of libxfcegui4 were affected -- don't currently know. Signed-off-by: Eygene Ryabinkin --- libxfcegui4/session-client.c | 18 ++++++++++-------- 1 files changed, 10 insertions(+), 8 deletions(-) diff --git a/libxfcegui4/session-client.c b/libxfcegui4/session-client.c index 4f036ec..88b66d6 100644 --- a/libxfcegui4/session-client.c +++ b/libxfcegui4/session-client.c @@ -335,9 +335,11 @@ logout_session (SessionClient * session_client) static void disconnect (SessionClient * session_client) { - SmcCloseConnection ((SmcConn) session_client->session_connection, 0, - NULL); - session_client->session_connection = NULL; + if (session_client->session_connection != NULL) { + SmcCloseConnection ((SmcConn) session_client->session_connection, + 0, NULL); + session_client->session_connection = NULL; + } session_client->current_state = SESSION_CLIENT_DISCONNECTED; gdk_set_sm_client_id (NULL); } @@ -759,11 +761,11 @@ client_session_new_full (gpointer data, SessionRestartStyle restart_style, { session_client->current_directory = g_strdup (g_get_home_dir ()); } - session_client->clone_command = clone_command; - session_client->resign_command = resign_command; - session_client->restart_command = restart_command; - session_client->discard_command = discard_command; - session_client->shutdown_command = shutdown_command; + session_client->clone_command = g_strdupv(clone_command); + session_client->resign_command = g_strdupv(resign_command); + session_client->restart_command = g_strdupv(restart_command); + session_client->discard_command = g_strdupv(discard_command); + session_client->shutdown_command = g_strdupv(shutdown_command); session_client->shutdown = FALSE; session_client->save_phase_2 = NULL; -- 1.6.2.4