From dc60a80b862a2e88b1179e8478b6d1ffb7c8249f Mon Sep 17 00:00:00 2001 From: Pavel Roskin Date: Sun, 16 Oct 2016 23:41:05 -0700 Subject: Memory leak fix: keep X server path in the parameter list g_cfg->xorg_params, g_cfg->vnc_params and g_cfg->rdp_params don't have auto_free enabled, so removing an item from one of those lists won't free its contents. It's better not to change those lists, as they represent the actual config file and could be reused. Instead, omit the 0th parameter (the executable path) from copying to xserver_params. Found by Valgrind. --- sesman/session.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'sesman') diff --git a/sesman/session.c b/sesman/session.c index 031b27f6..581af1ae 100644 --- a/sesman/session.c +++ b/sesman/session.c @@ -672,14 +672,13 @@ session_start_fork(int width, int height, int bpp, char *username, /* get path of Xorg from config */ xserver = g_strdup((const char *)list_get_item(g_cfg->xorg_params, 0)); - list_remove_item(g_cfg->xorg_params, 0); /* these are the must have parameters */ list_add_item(xserver_params, (tintptr) g_strdup(xserver)); list_add_item(xserver_params, (tintptr) g_strdup(screen)); /* additional parameters from sesman.ini file */ - list_append_list_strdup(g_cfg->xorg_params, xserver_params, 0); + list_append_list_strdup(g_cfg->xorg_params, xserver_params, 1); /* make sure it ends with a zero */ list_add_item(xserver_params, 0); @@ -706,7 +705,6 @@ session_start_fork(int width, int height, int bpp, char *username, /* get path of Xvnc from config */ xserver = g_strdup((const char *)list_get_item(g_cfg->vnc_params, 0)); - list_remove_item(g_cfg->vnc_params, 0); /* these are the must have parameters */ list_add_item(xserver_params, (tintptr)g_strdup(xserver)); @@ -723,7 +721,7 @@ session_start_fork(int width, int height, int bpp, char *username, /* additional parameters from sesman.ini file */ //config_read_xserver_params(SESMAN_SESSION_TYPE_XVNC, // xserver_params); - list_append_list_strdup(g_cfg->vnc_params, xserver_params, 0); + list_append_list_strdup(g_cfg->vnc_params, xserver_params, 1); /* make sure it ends with a zero */ list_add_item(xserver_params, 0); @@ -738,7 +736,6 @@ session_start_fork(int width, int height, int bpp, char *username, /* get path of X11rdp from config */ xserver = g_strdup((const char *)list_get_item(g_cfg->rdp_params, 0)); - list_remove_item(g_cfg->rdp_params, 0); /* these are the must have parameters */ list_add_item(xserver_params, (tintptr)g_strdup(xserver)); @@ -751,7 +748,7 @@ session_start_fork(int width, int height, int bpp, char *username, /* additional parameters from sesman.ini file */ //config_read_xserver_params(SESMAN_SESSION_TYPE_XRDP, // xserver_params); - list_append_list_strdup(g_cfg->rdp_params, xserver_params, 0); + list_append_list_strdup(g_cfg->rdp_params, xserver_params, 1); /* make sure it ends with a zero */ list_add_item(xserver_params, 0); -- cgit v1.2.1