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.
master
Pavel Roskin 8 years ago
parent e17a56efb6
commit dc60a80b86

@ -672,14 +672,13 @@ session_start_fork(int width, int height, int bpp, char *username,
/* get path of Xorg from config */ /* get path of Xorg from config */
xserver = g_strdup((const char *)list_get_item(g_cfg->xorg_params, 0)); 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 */ /* these are the must have parameters */
list_add_item(xserver_params, (tintptr) g_strdup(xserver)); list_add_item(xserver_params, (tintptr) g_strdup(xserver));
list_add_item(xserver_params, (tintptr) g_strdup(screen)); list_add_item(xserver_params, (tintptr) g_strdup(screen));
/* additional parameters from sesman.ini file */ /* 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 */ /* make sure it ends with a zero */
list_add_item(xserver_params, 0); 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 */ /* get path of Xvnc from config */
xserver = g_strdup((const char *)list_get_item(g_cfg->vnc_params, 0)); 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 */ /* these are the must have parameters */
list_add_item(xserver_params, (tintptr)g_strdup(xserver)); 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 */ /* additional parameters from sesman.ini file */
//config_read_xserver_params(SESMAN_SESSION_TYPE_XVNC, //config_read_xserver_params(SESMAN_SESSION_TYPE_XVNC,
// xserver_params); // 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 */ /* make sure it ends with a zero */
list_add_item(xserver_params, 0); 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 */ /* get path of X11rdp from config */
xserver = g_strdup((const char *)list_get_item(g_cfg->rdp_params, 0)); 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 */ /* these are the must have parameters */
list_add_item(xserver_params, (tintptr)g_strdup(xserver)); 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 */ /* additional parameters from sesman.ini file */
//config_read_xserver_params(SESMAN_SESSION_TYPE_XRDP, //config_read_xserver_params(SESMAN_SESSION_TYPE_XRDP,
// xserver_params); // 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 */ /* make sure it ends with a zero */
list_add_item(xserver_params, 0); list_add_item(xserver_params, 0);

Loading…
Cancel
Save